Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Simple application using Timer in Action Script 3




package
{
import flash.display.Sprite;
import flash.events.TimerEvent;
import flash.utils.Timer;

public class TimerClass extends Sprite
{
var _square:Sprite;
var _circle:Sprite;

public function TimerClass()
{
_square = new Sprite();

_circle = new Sprite();

_square.graphics.beginFill(0x660033);
_square.graphics.drawRect(0,0,100,100);
_square.graphics.endFill();

_circle.graphics.beginFill(0x660033);
_circle.graphics.drawCircle(50,50,50);
_circle.graphics.endFill();

addChild(_square);
addChild(_circle);

_circle.x = 200; // xy postion
_circle.y = 200;

_square.x = 100; // xy postion
_square.y = 50;

var sqTimer: Timer = new Timer(50,0);
sqTimer.addEventListener(TimerEvent.TIMER,SquareTimer);
sqTimer.start();

var cTimer:Timer = new Timer (50,0);
cTimer.addEventListener(TimerEvent.TIMER,CircleTimer);
cTimer.start();

}
public function SquareTimer(event:TimerEvent):void
{
if (_square.x _square.x++;
}
public function CircleTimer(event:TimerEvent):void
{
if (_circle.x >=150)
_circle.x--;
}
}
}


This post first appeared on IAK - Computer Software And Hardware, please read the originial post: here

Share the post

Simple application using Timer in Action Script 3

×

Subscribe to Iak - Computer Software And Hardware

Get updates delivered right to your inbox!

Thank you for your subscription

×