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

Count down clock Flash CS6

Community Beginner ,
Apr 27, 2014 Apr 27, 2014

Hi there I have created a Countdown clock in Flash CS6 the code will run but nothing seems to happen the clock does not start to count down can anyone please help: I have been at it for days and it is driving me insane

Code is below

this.onEnterFrame = function()

{

var today:Date = new Date();

var currentYear = today.getFullYear();

var currentTime = today.getTime();

var targetDate:Date = new Date(2016,7,25);

var targetTime = targetDate.getTime();

var timeLeft = targetTime - currentTime;

var sec = Math.floor(timeLeft/1000);

var min = Math.floor(sec/60);

var hours = Math.floor(min/60);

var days = Math.floor(hours/24);

sec = String(sec % 60);

if(sec.length < 2){

  sec = "0" + sec;

}

min = String(min % 60);

if(min.length < 2){

  min = "0" + min;

}

hours = String(hours % 24);

if(hours.length < 2){

  hours = "0" + hours;

}

days = String(days);

if(timeLeft > 0 ){

  var counter:String = days + ":" + hours + ":" + min + ":" + sec;

  time_txt.text = counter;

}else{

  trace("TIME'S UP");

        var newTime:String = "00:00:00:00";

        time_txt.text = newTime;

        delete (this.onEnterFrame);

}

}

Thanks Joel

TOPICS
ActionScript
4.6K
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
LEGEND ,
Apr 27, 2014 Apr 27, 2014

While I cannot say if it is providing the correct information, it is providing a countdown.  What I see when I start it is...

850:10:40:32

(which changes due to time changing)

Have you assigned the instance name to the textfield?  Is the textfield's text color different than the background of the stage?

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
Community Beginner ,
Apr 27, 2014 Apr 27, 2014

That is really strange all I can see are the placeholders and no countdor

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
Community Beginner ,
Apr 27, 2014 Apr 27, 2014

Just a little update I took on the first line of code and it show me the remaining days but does not count the mm down I have to keep refreshing the page.

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
LEGEND ,
Apr 27, 2014 Apr 27, 2014

Here is a link to a file I made where I just copied in your code and created /named the textfield.  Maybe you will be able to find some difference.  If not try doing what I did with a new file.

http://www.nedwebs.com/Flash/countdown.fla

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
Community Beginner ,
Apr 27, 2014 Apr 27, 2014

Thanks Ned

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
Community Beginner ,
Apr 27, 2014 Apr 27, 2014

Hi Ned

Once again thank you for your helpI am so sorry to bother you with this but when I ran the code it shows up as a blank screen but as soon as i take the top function out of the equation it works by showing me the time remaining but it is not counting down.

I am sure it is all my fault because I am new to this and thought this would be striaght forward it is a pity I can not skype you It is a mission now I have seen it done on youtube and it works right away but not for mes says trying to connect with Flash something about a font not being enabled.

Thanks again

Joel 

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
New Here ,
Apr 02, 2016 Apr 02, 2016
LATEST

Hi Murphy. You don´t have a file .fla .... countdown in AS3 (20 minutes) for one presentation. I ´am a principant in Flash. Thanks

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
New Here ,
Sep 25, 2014 Sep 25, 2014

Ah thank you so much Ned I just googled for this File and came here. Your Link worked for me on my Adobe flash CS6. But now I'm having trouble and confused about changing the time to at least I only want to have 2 minutes and 40 seconds wich or what or how do i exactually change it so i can get that? Please if you can let me know what to do thanks..

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