How to call actionscript functions inside the swf file loaded in swfLoader of my flex app?
I have a swf file sample.swf which has its 开发者_如何学JAVAactionscript 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... :)
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.
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.
精彩评论