I’d like to stay as far away from putting code in the timeline and manually putting objects on the stage as possible, so I’m trying to dynamically create a MovieClip and draw things on certain frames. I came across MovieClip.addFrameScript() which seems awesome except I haven’t been able to get it to work yet. Here is some simple code, I know there’s a step I’m missing…
var mc:MovieClip = new MovieClip();
mc.addFrameScript(0, onFrame1);
addChild(mc);
function onFrame1():void
{
trace("Main::onFrame1(): " + mc.currentFrame);
}
addEventListener(Event.ENTER_FRAME, test);
function test(event:Event):void
{
trace(mc.currentFrame);
}
mc.gotoAndStop(2);
This seems like it would work, but the only output I get is from the “test” function. Any help?