PDA

View Full Version : Triggering Flash animation from within Flex


Elephantium
07-17-2008, 09:53 PM
Hello,

I have a Flash file with a simple animation in it. The artwork and animation are defined on a component in the Library, and I'm calling stop(); in the first frame. The Flash file gets published as a SWF.

In Flex, I have a SWFLoader to load the animation file. The SWF displays the static artwork just fine, but it doesn't show the animation. So far, I haven't been able to figure out how to start the animation up.

I've tried the following from within Flex:

swfLoader.content.play(); //silently fails
swfLoader.content.gotoAndPlay(2); //silently fails
swfLoader.content.gotoAndPlay("animationFrameLabel"); //fails with an error message saying that the label can't be found in Scene 1
swfLoader.content.startAnimation(); //fails with an error saying that startAnimation isn't a function

* I defined the startAnimation() function in the Flash source on frame 1.

Is there something obvious I'm missing about how to start a Flash animation (or even just call a function on a Flash object) from within Flex?

Elephantium
07-17-2008, 10:43 PM
I figured it out - I just needed to place some code in a frame on Scene 1 -- calls from the Flex code didn't have access to the stuff listed in the Library in the Flash project.