Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Start counting down!

Explorer ,
Dec 16, 2016 Dec 16, 2016

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?

TOPICS
ActionScript
562
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Dec 17, 2016 Dec 17, 2016
//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);
}
}
Translate
Community Expert ,
Dec 17, 2016 Dec 17, 2016
LATEST
//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);
}
}
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines