Is it possible to create a MovieClip using ActionScript 3 code or MXML

actionscript-3flex3mxml

I'm using the Flex 3 SDK and the free FlashDevelop IDE.

As I don't have FlexBuilder or Flash CS4 Professional I cannot make MovieClips graphically.

So instead I want to create a simple MovieClip using code or MXML. For example, lets say I want to create a MovieClip with 3 frames, and load a bitmap into each frame to create a simple animation.

Is this possible? I've had a good google around and the only examples I can find are of loading existing MovieClips and adding them to a stage.

Best Answer

You can create a movieclip with this simple code:

var mc:MovieClip = new MovieClip();
stage.addChild(mc);

That is of cause just and empty movieclip, you can draw on it with graphics property (see here).

As far as I know there is no way to create frame with actionscript. Though there might be some undocumented methods. There are some functions that do not appear in the documentation (like the addFrameScript method).

I would say the best way (if you absolutly can not use the Flash CS4), would be to have a series of Loader objects, and the hide and show them on every in sequence. Just put them in an array and listen for the enterFrame event. You can load in the bitmaps in the Loader objects.

If you use the links and checkout the examples in the documentation, I think you should be able to figure it out.