Metin Ilhan
Metin Ilhan

Reputation: 120

can't get movieClip from loaded swf

With following code I import an external swf file. When I try to reach a movieClip that is named as temaResim in imported swf, Flash gives me error ,cant find the movieclip. I am pretty sure that I have temaResim in imported swf file, any help will be very useful.

Thanks guys.

function temaYukle(temaNo)
		{
			var resim:URLRequest = new URLRequest(yolum+"videolar/bilisselbecerilermodulu/17/"+temaNo+".swf");
			var img:Loader = new Loader();
			img.contentLoaderInfo.addEventListener(Event.COMPLETE, imageLoaded);
			img.load(resim);
			function imageLoaded(e:Event):void
			{
				setRegPoint(img,img.width/2,img.height/2);

				if (temaNo==temam)
				{
					trace(e.target);
					tema = e.currentTarget.content as MovieClip;
					img.scaleX *=  0.85;
					img.scaleY *=  0.85;
					img.x = stage.stageWidth / 2;
					img.y = stage.stageHeight / 2 - 20;
					addChildAt(img,0);
// here comes error    					
trace(tema.temaResim);
					
					temaMaske();
				}
              }
          }

I worked on imported swf file When i import onther image to library of imported swf and set it's instance name as temaResim it works but When I try the image that ı have to, it dosn't work.

Upvotes: 0

Views: 67

Answers (3)

Metin Ilhan
Metin Ilhan

Reputation: 120

İt is unbelievable but true, I have to change the ımage That has name temaResim, Now it works,

Upvotes: 1

HITMAN
HITMAN

Reputation: 548

use Bracket syntax:

function temaYukle(temaNo)
    {
        var resim:URLRequest = new URLRequest(yolum+"videolar/bilisselbecerilermodulu/17/"+temaNo+".swf");
        var img:Loader = new Loader();
        img.contentLoaderInfo.addEventListener(Event.COMPLETE, imageLoaded);
        img.load(resim);
        function imageLoaded(e:Event):void
        {
            setRegPoint(img,img.width/2,img.height/2);

            if (temaNo==temam)
            {
                trace(e.target);
                tema = e.currentTarget.content as MovieClip;
                img.scaleX *=  0.85;
                img.scaleY *=  0.85;
                img.x = stage.stageWidth / 2;
                img.y = stage.stageHeight / 2 - 20;
                addChildAt(img,0);
// here comes error                     
trace(img.content["temaResim"]);

                temaMaske();
            }
          }
      }

I hope this helps.

Upvotes: 1

Andre Lehnert
Andre Lehnert

Reputation: 531

Not the LoaderInfo holds the content ;-)

tema = e.currentTarget.loader.content as MovieClip;

Upvotes: 0

Related Questions