Skip to main content
Participant
November 29, 2017
Answered

Can't make countdown work?

  • November 29, 2017
  • 5 replies
  • 603 views

Doing a project and having some doubts. As yesterday I asked around something and I got to know a lot of new things I didn't thought before and as I'm still learning, I'm now trying to make a 10 minute countdown.

My question is not exactly for you to solve my problem, but how I can understand how to make it work based on what I know for now!

I've used some codes from forums and other youtube tutorials and random links I found on google (some of them outdated). But I can't make it work. I've tried with an empty textbox with a instance name I call on my code, it doesn't work. I've tried to make also a textbox with some other kind of code based on a date countdown I found... Also doesn't work.

I'm using Adobe Animate but I think I'm doing a wrong approach.

Am I doing something wrong? I have like more than 10 tabs opened with this question... Which kind of script I need to make it work?

Can you teach me the difference between these scripts?

This topic is closed to new replies. Start a new post to keep the conversation going.
Correct answer kglad

var time_duration_ms:int = 10*60*1000;

var startTime:Number;

startTimer()

function startTimer():void{

startTime = new Date().time;

this.addEventListener(Event.ENTER_FRAME,timeF);

}

function timeF(e:Event):void{

// display whatever - ? format_as timeF(new Date.time-startTime);  // define format_as_timeF

if(new Date().time>=startTime+time_duration_ms){

this.removeEventListener(Event.ENTER_FRAME,timeF);

endTimer()

}

}

function endTimer():void{

// do whatever

}

5 replies

Community Expert
November 30, 2017
Legend
November 30, 2017

You have failed to mention whether you're working on an AS3 or Canvas project.

kglad
Community Expert
kgladCommunity ExpertCorrect answer
Community Expert
November 29, 2017

var time_duration_ms:int = 10*60*1000;

var startTime:Number;

startTimer()

function startTimer():void{

startTime = new Date().time;

this.addEventListener(Event.ENTER_FRAME,timeF);

}

function timeF(e:Event):void{

// display whatever - ? format_as timeF(new Date.time-startTime);  // define format_as_timeF

if(new Date().time>=startTime+time_duration_ms){

this.removeEventListener(Event.ENTER_FRAME,timeF);

endTimer()

}

}

function endTimer():void{

// do whatever

}

kasterniAuthor
Participant
November 29, 2017

Thank you so much!

But I still can't make it work as I don't know how to properly manipulate that...

kglad
Community Expert
Community Expert
November 30, 2017

what can't you get to work?