Jump to content
Search Community

Accessing loader content

bartpop test
Moderator Tag

Recommended Posts

I'm having trouble figuring out the correct syntax to access my content. I'm hoping you can set me straight :?

 

I have a SWFLoader that loads it's content into a container Sprite that I created, like so:

 myContainer = new Sprite();
addChildAt(myContainer,0);

var myLoader:SWFLoader = new SWFLoader(mySWF.swf, {name:"mySWF", container:myContainer});
myLoader.load();

 

I'm trying to access a public function that was part of the mySWF class definition, but can't figure out the syntax to get at it. myContainer.getChildAt(0).name returns "mySWF", (type = "ContentDisplay"). How would I access a function "myFunction" that's part of the mySWF class? I've tried every combination I can think of: myContainer.getChildAt(0).myFunction, myContainer.getChildAt(0).content.myFunction, myContainer.getChildAt(0).rawContent.myFunction... just can't seem to find the correct path.

Link to comment
Share on other sites

Or simply cast the rawContent as an Object, like Object(myLoader.rawContent).myFunction()

 

The issue simply has to do with data typing in Flash and the compiler sees that rawContent is technically a DisplayObject and not all DisplayObjects have a "myFunction()" function, so it burps. If, however, you type it as an Object or MovieClip (assuming your root class did indeed extend a MovieClip), those are "dynamic" classes that can contain pretty much any property/method, so the compiler doesn't complain.

 

Hope that makes sense.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...