Solved

Flex 4  12 Second Countdown with progress bar

Posted on 2011-02-20
3
1,246 Views
Last Modified: 2012-05-11
<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
Comment
Question by:yahoolane
  • 2
3 Comments
 
LVL 17

Accepted Solution

by:
deepanjandas earned 500 total points
ID: 34940062
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
 
LVL 1

Author Comment

by:yahoolane
ID: 34957811
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
 
LVL 17

Expert Comment

by:deepanjandas
ID: 34957855
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Remember last page selection - swf file 3 283
Flex 3 trace output 13 723
debugger flash 10 608
air/as3 : is there a way to simulate TouchEvents? 1 394
First things first - Preparation We need all the part for this install and it's much nicer to have them all on hand when you need them so here's what's required. Download Eclipse 3.5 32 bit (I like the Classic flavour) from here. (http://www.e…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now