You are here: Recent News » Projects » Kairos » Tutorials

 

Tutorials

Tags : ,

What those tutorials are about ?

Those tutorials show how to use the basics objects Kairos provide in your applications, but You will also learn how time is handled by Kairos’ objects.

Understand time in Kairos

Kairos time management is quite different than how Flash usually work. The main difference is that all objects work on a second-based unit, result that the accuracy of some animation or callbacks, such as in MovieClipRT, IntervalRT or TimeoutRT classes, is lower than what the Flash Player offer. This approach fit well to game where perceived speed of the animations and synchronisation between events and animations is a big part of the gameplay, but it wouldn’t be enough accurate when you need to have a precision of 1 milliseconds.

Using MovieClipRT object

The MovieClipRT class offer you to handle the animation speed of a MovieClip.

Let say we have a MovieClip in the library called Animation. The swf framerate is set to 24 fps.

import com.kairos.motion.MovieClipRT;
 
// Creating the movieclip we want to animate with kairos, and one as benchmark.
var benchMC : MovieClip = _root.attachMovie( "Animation", "_benchMC", 0 );
var targetMC : MovieClip = _root.attachMovie( "Animation", "_targetMC", 1, { _x:50 } );
 
// Creating the time controller for the movieclip, and define it's speed.
var targetMCController : MovieClipRT = new MovieClipRT ( targetMC, 24 );
 
// Start the animation
targetMCController.start();

We have set the MovieClip’s speed to 24 fps. As in flash, by default the animation loop at the end of the timeline.

To prevent the MovieClip for looping just pass false as 3rd argument in the constructor.

var targetMCController : MovieClipRT = new MovieClipRT ( targetMC, 24, false );

For the moment the MovieClipRT mc run at the same speed than the benchmark one. Now just set the swf framerate to 80 fps and compile, the second mc may visually run at 24fps.

Dynamically change the speed of the animation

To change the speed of the animation at runtime, just use the getFramerate and setFramerate method of the MovieClipRT object.

targetMCController.setFramerate( 48 );
targetMCController.setFramerate( animTargetController.getFramerate() + 10 );

Using IntervalRT and TimeoutRT

Coming soon

Using Tweens

Coming soon

Building custom objects using RTObject

Coming soon

Controlling time scale with Kairos

Coming soon

projects/kairos/tutorials.txt · Last modified: 2007/04/30 05:07 by mickro