Fahim Akhter
Fahim Akhter

Reputation: 1625

Error Referencing Externally loaded SWF

I'm loading an swf say "test.swf" which gets loaded in imageLoader , so I can get its content by :

imageLoader.content

So if I wanted one of the movieClips inside it I would do this :

imageLoader.content.testMovie.transform.colorTransform = someTransformation;

But when I do this, since the movie is not loaded the file is not compiled and gives me an error your referring to something that is not there. How else am I supposed to reference a content that will be loaded later?

Upvotes: 0

Views: 180

Answers (2)

Amarghosh
Amarghosh

Reputation: 59451

Wait till it is loaded. Listen to its complete event and access content from there.

imageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoad);
function onLoad(e:Event):void
{
  MovieClip(imageLoader.content).testMovie.transform.colorTransform = someTransformation;
}

If testMovie is yet another dynamically loaded SWF, wait till it is loaded - listen to the complete event dispatched by testMovie.contentLoaderInfo.

Even better, if you have access to the loaded SWF, dispatch a custom event from there when testMovie is loaded and listen to it from the main SWF.

Upvotes: 1

danjp
danjp

Reputation: 727

You can't reference something that hasn't loaded. If you want to apply a transform you can do that on the parent clip but this might not be what you are after.

Upvotes: 0

Related Questions