Papa De Beau
Papa De Beau

Reputation: 3828

Get Child of loader from externally loaded swf

READY? Here it is:

var TheLoader:Object = parentObj.TheExit as Object;

This line gets me to the swf I loaded and I can now change the alpha, move it etc...

BUT HOW HOW HOW... do I get one of its children and control get that same control?

Example Code:

TheLoader.TheChild.alpha = .3; // Does not work!

5 days on this issue is WAY TOO LONG! Here is the 3rd post with the same issue but more detail. as3 externally loaded swf from network to control externally loaded swf from network

I just made this shorter to get attention to the ONE LINE I NEED!!!

THANKS!

Upvotes: 0

Views: 1230

Answers (1)

Mike Welsh
Mike Welsh

Reputation: 1559

If you look at the documentation for Loader, you'll see that it has a content property. This is how you access your loaded content. So, for example, if TheLoader is a Loader, and if TheChild was an instance on the timeline of the loaded SWF, you could do:

var child : Sprite = MovieClip(TheLoader.content).TheChild;

This child is not available until the content has been actually loaded, so be sure to listen to for the COMPLETE event on the Loader's contentLoaderInfo before accessing the content:

TheLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoaded);

function onLoaded(event : Event):void
{
    trace(MovieClip(loader.content).theChild);
}

Also note that you may run into security issues if the loader and loadee SWFs are not on the same domain. In this case, you will have to call Security.allowDomain in the SWFs to allow the cross-scripting.

Upvotes: 1

Related Questions