开发者

AS3 Timer class [closed]

开发者 https://www.devze.com 2023-04-05 03:57 出处:网络
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical andcannot be reasonably answered in its current form. For help clari
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. 开发者_运维技巧 Closed 11 years ago.

I need to create a timer using as3 timer class or some other class. And every 10 second i want to do some alert or trace something. Timer wont stop at any time. And every 10 second we can do some stuff.


The class of course would be the Timer class.
Here is a simple example to get you started.

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

public class TimerExample extends Sprite 
{
    public function TimerExample() 
    {
        var timer:Timer = new Timer(10000);
        timer.addEventListener(TimerEvent.TIMER, timerHandler);
        timer.start();
    }

    public function timerHandler(event:TimerEvent):void 
   {
        trace("timerHandler: " + event);
    }
}
}


Couldn't be simpler:

var t:Timer = new Timer(10000);
t.addEventListener("timer", doSomething);
t.start();

function doSomething(event:*):void {
    trace("something");
}
0

精彩评论

暂无评论...
验证码 换一张
取 消