Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1273
  • Last Modified:

Flex 4 12 Second Countdown with progress bar

<mx:ProgressBar id="timerP" x="0" y="73" labelPlacement="right" label="" />

Here I have a progress bar
I want to give the user 12 seconds to choose
they can press a button or default action
Show a Nice indicator as time runs out

I do not know how the timer works,
I feel I can Like this
private var baseTimer:int;
private var timer:Timer

private const TIMER_INTERVAL:int = 10;
timer = new Timer(TIMER_INTERVAL);
timer.addEventListener(TimerEvent.TIMER, updateTimer);

private function updateTimer(evt:TimerEvent):void {
      var d:Date = new Date(getTimer() - baseTimer);
      var sec:String = (SEC_MASK + d.seconds).substr(-SEC_MASK.length);
         counter.text = String(min + ":" + sec + "." + ms);

How to inc progress bar
and default if tmes run out

      }

0
yahoolane
Asked:
yahoolane
  • 2
1 Solution
 
deepanjandasCommented:
You have to create a custom preloader as the Preloader component
private const TIMER_COUNT:int = 12;
private var timer:Timer;

private function init():void {
    timer = new Timer(1000, TIMER_COUNT);
    timer.addEventListener(TimerEvent.TIMER, onTimer, false, 0, true);
    timer.addEventListener(TimerEvent.TIMER_COMPLETE, onTimerComplete, false, 0, true);
    timer.start();
}

private function onTimer(event:TimerEvent):void {
    var progress:Number = timer.currentCount / TIMER_COUNT * 100;
    //Pass this progress variable to draw your preloader.
}

private function onTimerComplete(event:TimerEvent):void {
    timer.removeEventListener(TimerEvent.TIMER, onTimer);
    timer.removeEventListener(TimerEvent.TIMER_COMPLETE, onTimerComplete);
    //do it here
}

Open in new window


You can get some sample code for drawing preloaders here:
http://iamjosh.wordpress.com/2007/12/18/flex-custom-preloader/
http://www.riagora.com/2010/08/custom-flex-4-preloader/

Warm Regards
Deepanjan Das
0
 
yahoolaneAuthor Commented:
I wanted to include a progress bar or indicator
For Count Dowm

I was playing with progress bar in 'manual' mode

is there a better way
0
 
deepanjandasCommented:
The above 2 links will help you to create a custom preloader.

Then pass the progress variable from onTimer method to show the progress.

Warm Regards
Deepanjan Das
0

Featured Post

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now