A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: How to make a function be executed at the end of a countdown? AS3?

  1. #1
    Junior Member
    Join Date
    Sep 2013
    Posts
    1

    How to make a function be executed at the end of a countdown? AS3?

    I need to know how to make a countdown in AS3 that activates a function when it reaches zero.

    Thanks!

  2. #2
    Senior Member
    Join Date
    Nov 2012
    Posts
    106
    Here is a solution using code snippets
    Code:
    import flash.events.TimerEvent;
    
    var fl_TimerInstance:Timer = new Timer(1000, 10);
    fl_TimerInstance.addEventListener(TimerEvent.TIMER, fl_TimerHandler);
    fl_TimerInstance.addEventListener(TimerEvent.TIMER_COMPLETE, TimesUp);
    fl_TimerInstance.start();
    
    var fl_SecondsElapsed:Number = 10;
    Countdown.text =String(fl_SecondsElapsed);
    
    function fl_TimerHandler(event:TimerEvent):void
    {   fl_SecondsElapsed--;
    	trace("Seconds elapsed: " + fl_SecondsElapsed);
    	Countdown.text =String(fl_SecondsElapsed);
    
    	
    }
    function TimesUp(e:TimerEvent){
    	trace("Times Up!~")
    }

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