This tutorial will show you how to create an animation whose motion is syncronized with a specified time interval. To make this type of animation with ActionScript, we use the Timer Class.
The Timer is a class for executing code after a specified time interval. Each Timer object dispatches TimerEvent.TIMER events at a programmer specified frequency.
The function called by TIMER event and executed at that frequency can be used to change the visual aspect of an object, so with frequent modifications of the object it can create the effect of animation.
The animation created with TimerEvent does not depend on the number of frames per second FPS (like the one with ENTER_FRAME), but if the system or the Flash runtime is busy at the time a Timer is scheduled to execute its functions, the execution will be delayed.
var name_var:Timer = new Timer(frequency, repetitions);- The time interval (frequency) can also be set and changed with the property delay, and the number of repetitions with repeatCount (the value 0 indicates no limit)
function functionName(evt:TimerEvent):void { // code to execute }- This function must define a single parameter whose datatype is TimerEvent.
instanceTimer.addEventListener(TimerEvent.TIMER, functionName);
instanceTimer.start();
var dimens:Number = 0.12; // sets a sizing coefficient (12%) var move_y:Number = 23; // sets an Y motion distance var rotire:Number = 30; // Degrees for rotation // Create instance of Timer class, with the frequency half a second and maximum 6 repetitions var jumpTimer:Timer = new Timer(500, 6); // The Function that will be called by the TimerEvent.TIMER function jumpLand(evt:TimerEvent):void { // Modify the object's size with the coeficient value (%) from "dimens" drept1.scaleX += dimens; drept1.scaleY += dimens; drept1.rotation -= rotire; // rotates drept1.y -= move_y; // moves vertically } // The function that will be called by the TimerEvent.TIMER_COMPLETE function atTimerComplete(evt:TimerEvent):void { // Changes in an opposite way the values for sizing and vertical motion dimens *= -1; move_y *= -1; evt.target.reset(); // Resets the number of repetitions (to start from 0) evt.target.start(); // Starts the TIMER again } // register an event listener TimerEvent.TIMER, to "jumpTimer" instance jumpTimer.addEventListener(TimerEvent.TIMER, jumpLand); // register an event listener TimerEvent.TIMER_COMPLETE, to "jumpTimer" instance jumpTimer.addEventListener(TimerEvent.TIMER_COMPLETE, atTimerComplete); jumpTimer.start(); // Starts the TIMER- When the number of repetitions reaches the specified value (in this case 6), the event TimerEvent.TIMER_COMPLETE is dispatched. In the function called by this event ( atTimerComplete() ) the animation's motion direction changes, the number of repetitions resets to 0, and the start() method is invoked to start again the TimerEvent.Timer.
<table><tr> <th>Title 1</th> <th>Title 2</th> </tr></table>
.some_class { line-height: 150%; }
document.getElementById("id_button").onclick = function(){ window.open("http://coursesweb.net/"); }
$ar_dir = scandir("dir_name"); var_export($ar_dir);