I'm creating a game in ActionScript 3.0 using the FlashPunk game engine and the FlashDevelop SDK. I've created my own MovieClip class that takes a preloaded movie clip file.
public function MyMovieClip(file:MovieClip, posX:int, posY:int, frameRate:int)
{
movieClip = file;
movieClip.x = posX;
movieClip.y = posY;
movieClip.stop();
FP.stage.addChild(movieClip);
timer = new Timer((1 / frameRate) * 1000);
timer.start();
timer.addEventListener(TimerEvent.TIMER, onTick);
}
The update for my movie clip is as follows:
private function onTick(e:TimerEvent):void
{
if (isRepeating)
{
if (movieClip.currentFrame == movieClip.totalFrames )
{
movieClip.gotoAndStop(0);
}
}
movieClip.nextFrame();
}
The problem that I'm having is that when I have multiple instances of the MyMovieClip class using the same swf file, only the last instance is rendered and is updated for each instance of the class that I have.(e.g 3 instances of MyMovieClip, the last instance is updates at 3 times the speed.)
If anymore info is needed I'll be happy to supply it.