How can I embed a MovieClip from a SWF into a Flex app without looping it?

Go To StackoverFlow.com

2

I'm stumped on this one, but it seems like something simple I'm overlooking.

My Flex app embeds (i.e., compiles in) another SWF's MovieClip, like so:

[Embed(source='assets/clips.swf', symbol='MyClip')] 
private var MyClip:Class;

... and then uses an mx:Image tag to display it:

<mx:Image source="{MyClip}" width="300" height="100" />

... but the resulting clip loops forever. I want it to play only once and then stop.

The source clip has a stop() action defined in its final frame, but I suspect that script is being stripped out at compile time, so I'm wondering how I can tell the Image tag, or MyClip class somehow, that the clip should not loop continuously.

Thanks in advance!

2012-04-04 00:49
by Christian Nunciato


0

I do not work with Flex, so these ideas are not something I know by practice; but here is what I have found:

If the SWF file contains any ActionScript code, Flex prints a warning during compilation and then strips out the ActionScript from the embed symbol. This means that you can only embed the symbol itself. -- http://livedocs.adobe.com/flex/3/html/help.html?content=embed_4.html

Also, I believe MyClip is a Class, and not an instance of that class on the stage. So . . . you have to do something like:

<mx:Image source="{new MyClip()}" width="300" height="100" />

or create a variable and work with it, like this example from Adobe docs.

If all this ends up being in the realm of truth, then you can play() and stop() as any other embedded SWF.

2012-04-04 02:54
by iND
Ads