A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: AS3 countdown timer problem

  1. #1
    Junior Member
    Join Date
    Jan 2008
    Posts
    15

    AS3 countdown timer problem

    Hi all, I need a timer that will hold 5 secs on say keyframe 20 then start again on keyframe 40 and keep repeating/restarting at additional keyframe intervals. The script below works only on frame 20. I would really appreciate any help with an example of how to get the timer function to work on multiple keyframes.

    var fl_TimerInstance:Timer = new Timer(1000, 5);
    fl_TimerInstance.addEventListener(TimerEvent.TIMER , fl_TimerHandler);
    fl_TimerInstance.start();

    var fl_SecondsElapsed:Number = 1;
    function fl_TimerHandler(event:TimerEvent):void{
    trace("Seconds elapsed: " + fl_SecondsElapsed);
    fl_SecondsElapsed++;
    if (fl_SecondsElapsed ==5) {
    gotoAndStop(20);
    }
    }

  2. #2
    Dignitary rynoe's Avatar
    Join Date
    Jan 2003
    Location
    Earth
    Posts
    760
    for five seconds you put:
    Code:
    var fl_TimerInstance:Timer = new Timer(1000, 4);
    because the second number is how many time it is repeated, not fired.


    To restart a timer you can call the reset method:
    Code:
    fl_TimerInstance.reset()
    [SIGPIC][/SIGPIC]

  3. #3
    Junior Member
    Join Date
    Jan 2008
    Posts
    15

    Smile Help with AS3 timer function

    Many thanks for the kind help. Issue now resolved.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center