views:

771

answers:

2

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!

+1  A: 

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();
Michael Brewer-Davis
The swf being embedded is not a flex app. It is a CS4 AS3 swf.
E-Madd
A: 

Are you able to load the swf into Flex at runtime rather than embed it? I've had good results loading swfs into Flex after launch, whereas embedding tends to be problematic for accessing a swf API.

Either use Loaders with eventListeners in a script or mx:SWFLoader in MXML with a listener on complete should work for you.

Pythovore