I have an swf file, published for Flash Player 9+ that contains two symbols. I am going to need one symbol which is actually a movie clip. This movie clip is named Jar and it comprises of two frames. The first frame is a picture of an okay jar. The second frame contains a picture of a broken jar. How do we embed and display this in Flex 3? (I will assume you are familiar with Flex 3) ...
import mx.core.MovieClipAsset;
import mx.controls.Image; [Embed(source="myassets.swf", symbol="Jar")]
[Bindable] public var JarClass:Class;
... That is about it when declaring it in Flex using Actionscript.
Now lets displaying using a function.
I made a function named init() which I call every time the CreationComplete event of the application is executed.
Here is the function:
private function init():void {
var myJar:MovieClipAsset = MovieClipAsset(new JarClass());
myJar.gotoAndStop(2); // Display the second frame
var zImage:Image = new Image();
zImage.source = myJar;
zImage.x = 40; zImage.y = 40; // add to the DisplayObject to make it visible addChild(zImage);
} // init
That's about it.
import mx.core.MovieClipAsset;
import mx.controls.Image; [Embed(source="myassets.swf", symbol="Jar")]
[Bindable] public var JarClass:Class;
... That is about it when declaring it in Flex using Actionscript.
Now lets displaying using a function.
I made a function named init() which I call every time the CreationComplete event of the application is executed.
Here is the function:
private function init():void {
var myJar:MovieClipAsset = MovieClipAsset(new JarClass());
myJar.gotoAndStop(2); // Display the second frame
var zImage:Image = new Image();
zImage.source = myJar;
zImage.x = 40; zImage.y = 40; // add to the DisplayObject to make it visible addChild(zImage);
} // init
That's about it.
Comments