R – Flex: How to call function of embedded swf

actionscriptactionscript-3apache-flex

I have a Flex 3.4 app that embeds a swf with mx:SwfLoader…

That swf has a public function named "playIt". I've tried dispatching events to gettingHere.content, casting gettingHere.content as a MovieClip and other stuff…

var swfApp:MovieClip = MovieClip(gettingHere.content);
if (swfApp.hasOwnProperty("playIt")) {
var helloWorld:Function = (swfApp["playIt"] as Function);
helloWorld();
}

to no avail. Help!

Best Answer

See the example here for interacting with a loaded Flex application.

Essentially:

var swfLoader:SWFLoader; // assuming loading complete
var loadedSM:SystemManager = SystemManager(swfLoader.content);
var loadedApp:Object = loadedSM.application;

app.playIt();
Related Topic