2

I have a swf file sample.swf which has its actionscript class in Main.as. This Main.as has various objects declared as public in it. For instance lets consider an object myData of class MyData (in MyData.as).

I am loading this swf file in my AIR app using swfLoader. I want to know how do I access myData.func() using swfLoader.loaderInfo.content.

Thanks in advance... :)

2 Answers 2

2

in your init handler, it should be something like:

function myLoadHandler( e:Event )
{
    MyData( e.target.content.myDataInstance ).func();
}

where myLoadHandler is the event handler for the Event.INIT event (COMPLETE is fired when all the bytes are loaded, INIT is fired after the SWF is initialized and its members are accessible), and myDataInstance is the public reference to your MyData instance inside your child SWF.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks @gthmb. Just to add up to your valuable information. If not MyData (in case this class is present only in the swf and not in flex) you can use Object typecasting. I tried even this Object(swfLoader.content).myDataInstance.func(); and it worked too.
0

I have done this before. I can't recall the exact path to the data but a way to find out is using the debugger in flex. Add an Event.Complete event for the loader and add a breakpoint inside the complete function you call. Then add the swfLoader.loaderInfo.content to expression watch list and start drilling down to find what you are looking for. Note the path and try giving it a call in a test function.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.