package {
import flash.display.Sprite;
import flash.events.TimerEvent;
import flash.utils.Timer;
public class Main extends Sprite {
private var _square:Sprite;
private var _circle:Sprite;
public function Main( ) {
_square = new Sprite( );
_square.graphics.beginFill(0xff0000);
_square.graphics.drawRect(0, 0, 100, 100);
_square.graphics.endFill( );
addChild(_square);
_square.x = 100;
_square.y = 50;
_circle = new Sprite( );
_circle.graphics.beginFill(0x0000ff);
_circle.graphics.drawCircle(50, 50, 50);
_circle.graphics.endFill( );
addChild(_circle);
_circle.x = 100;
_circle.y = 200;
var squareTimer:Timer = new Timer(50, 0);
squareTimer.addEventListener(TimerEvent.TIMER, onSquareTimer);
squareTimer.start( );
var circleTimer:Timer = new Timer(100, 0);
circleTimer.addEventListener(TimerEvent.TIMER, onCircleTimer);
circleTimer.start( );
}
private function onSquareTimer(event:TimerEvent):void {
_square.x++;
}
private function onCircleTimer(event:TimerEvent):void {
_circle.x++;
}
}
}
|