Copy link to clipboard
Copied
How can I start a countdown from a single button? I am trying to do, however, without success.
I would like the time to run alone after pressing a particular button and pause when it reaches zero. I did only the part of the dynamic text and the discount of numbers, however, everything manual.
can anybody help me?
//var
var score:uint
score = 7;
counting.text = "" + score.toString();
// EventList
up.addEventListener(MouseEvent.CLICK, up1);
// Actions
function up1(Event:MouseEvent): void {
score -= 1;
counting.text = "" + score.toString();
if (score <= 0) {
score = 0;
}
move.gotoAndStop(2);
}
The stopwatch starts in seven seconds, I would like after pressing the "up" button to start counting down to zero and then pause the time.
can anybody help me? Please?
//var
var t:Timer=new Timer(1000,0);
t.addEventListener(TimerEvent.TIMER,timerF);
var score:uint score = 7;
counting.text = "" + score.toString();
// EventList
up.addEventListener(MouseEvent.CLICK, up1);
// Actions
function up1(Event:MouseEvent): void {
t.start();
}
function timerF(e:TimerEvent):void{
score -= 1;
counting.text = "" + score.toString();
if (score <= 0) {
score = 0;
t.stop();
} else {
move.gotoAndStop(2);
}
}
Copy link to clipboard
Copied
//var
var t:Timer=new Timer(1000,0);
t.addEventListener(TimerEvent.TIMER,timerF);
var score:uint score = 7;
counting.text = "" + score.toString();
// EventList
up.addEventListener(MouseEvent.CLICK, up1);
// Actions
function up1(Event:MouseEvent): void {
t.start();
}
function timerF(e:TimerEvent):void{
score -= 1;
counting.text = "" + score.toString();
if (score <= 0) {
score = 0;
t.stop();
} else {
move.gotoAndStop(2);
}
}
Find more inspiration, events, and resources on the new Adobe Community
Explore Now