Search code examples
flashanimationactionscriptframe-rate

What happens on each frame in a flash actionscript animation game


I am new to Flash, Actionscript and Animation. My background is Java.

I am trying to understand animation in flash. I am trying to know what happens in each frame of movie_clip. The flash stage is running at 12 or 60 fps. All items have different animation. Now how does the animation for 5-6 different objects in a game happens?

Is there a timestep or delta calculated? Is it same for all animations or different animations have to have different delta? Is the delta calculated at some event or in each frame.

Is it better to animate based on frames, i.e. for 60 frames put slightly different picture to make a character walk?

Is it better to animate programatically using actionscript gotoAndStop or some other goto frame function.

I am sorry if this question is not clear as I'm bit confused.

Thanks for help!


Solution

  • If you are animating on the timeline then the Flash Player will attempt to render the stage at the framerate you have set in the project properties. Each movie clip on the stage will be updated at this same rate. However, if you have complex animations, or many objects on the stage at once the Flash Player can have a hard time keeping up with that framerate, so it will run slower. The speed of the computer on which it is running also affects this. So if you set your movie to run at 30 fps, Flash will do its best to update the animations 30 times a second, but it may only run at an actual speed of 20 or 25. Or it may run at 30 most of the time, but drop when things get complicated. Note that it will not skip frames, it will play them more slowly.

    For this reason, it's often better to create animations programmatically so you can calculate a time delta and move the objects based on that. That way, if the frame rate drops the animation might get a little chunky, but things won't slow down. This can be really important in games.

    You will get the best performance by using sprite sheets and 'blitting' your objects to a bitmap canvas. Basically you put all the frames of an animation in a single image and then copy them out individually and composite them into a single large bitmap that represents the game screen. This will be much faster than putting each image on a separate frame in a movieClip.