topical media & game development
animation-ch19-Timer2.ax
animation-ch19-Timer2.ax
[swf]
[flash]
flex
package {
import flash.display.Sprite;
import flash.utils.Timer;
import flash.events.TimerEvent;
import flash.utils.getTimer;
public class @ax-animation-ch19-Timer2 extends Sprite
{
private var timer:Timer;
private var ball:animation_ch19_Ball;
public function @ax-animation-ch19-Timer2()
{
init();
}
init(s)
private function init():void
{
stage.frameRate = 1;
ball = new animation_ch19_Ball();
ball.y = stage.stageHeight / 2;
ball.vx = 5;
addChild(ball);
timer = new Timer(20);
timer.addEventListener(TimerEvent.TIMER, onTimer);
timer.start();
}
timer(s)
private function onTimer(event:TimerEvent):void
{
ball.x += ball.vx;
event.updateAfterEvent();
}
}
}
(C) Æliens
04/09/2009
You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.