Thursday, December 3, 2009

Synchronized Movie Clip

View SWF
View source
Stardust project homepage

The new SynchronizedMovieClip class is a StardustMovieClip subclass, which is for "time step synchronization" I mentioned in this article. In this demo you can notice that there's a slider bar for tweaking the time scale of the particle simulation (which tweaks the Emitter.stepTimeInterval property).

In the absence of the SynchronizedMovieClip class, the movie clips will play at the original speed even if the simulation time is scaled down, which is pretty logical since the frame rate is not changed, only the internal time scale for simulation changed.

Now the movie clips are SynchronizedMovieClip instances and the emitter has a StardustSpriteInit initializer and StardustSpriteUpdate action added to it, the movie clips can be synchronized with the particle simulation time scale. The StardustSpriteInit initializer stops the movie clips at the very beginning by calling the init() method defined in the IStardustSprite interface, which the StardustSpriteMovieClip class implements, and the StardustSpriteUpdate action sets the movie clips' frames according to the simulation time scale through the update() method, also defined in the IStardustSprite interface.

This is how the synchronization of movie clips and Stardust particle simulation is done.

No comments: