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

Countdown Timer

New Here ,
Jul 09, 2008 Jul 09, 2008
Hi i'm pretty new to flash but i'm trying to make a countdown timer. The timer should start at 30 minutes and 0 seconds and countdown to 0 when it reaches 0 id like it to then start counting back up. I'd be very thankful for any help you can give me.

Andrew.
TOPICS
ActionScript
2.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
Community Expert ,
Jul 09, 2008 Jul 09, 2008
you can use the timer class to call a function (about) every second. you'll need a variable to indicate you're counting down (or up) and you'll need to initialize a variable that will be decremented (or incremented) in your function. and you'll need a function to format your variable that's being decremented (or incremented) so it displays the time in your preferred format.
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
Guest
Jul 09, 2008 Jul 09, 2008
Here is the code for a simple timer I just made. It should work (though I didn't completely test it yet, but I will, and fix any bugs I find). It counts down 30 minutes, than up 30 minutes, then stops. I'll make another post explaining the code after.

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
Guest
Jul 09, 2008 Jul 09, 2008
Found some errors in my code, here's the new code:
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 ,
Jul 09, 2008 Jul 09, 2008
just had a go at a test movie for the code 2nd you gave me. Changed initial minutes var to 1 just so I wasnt hanging around for 30 mins. When the timer reached 0 it changed the minutes to -1 and started counting down seconds from 59 ie -1:59. I need it to go back up ie 0.1. And can you think of any way to get double figures in the clock.
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
Guest
Jul 09, 2008 Jul 09, 2008
Oh, whoops, sorry about that. Here's the newer working code. Also, what do you mean by double figures in the clock?

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 ,
Jul 09, 2008 Jul 09, 2008
that works now. For double figures i meant like 01:05 i dont know what you'd call that sort of a number. That doesn't really matter as long as it works. You wouldnt know how to change to background colour when the timer hits 0 would you, seem to be asking a lot here.
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 ,
Oct 04, 2017 Oct 04, 2017
LATEST

Hi. I am trying to make a countdown timer that counts down (live) for a forum. Is this what you guys are referring to? Also I can't see code on here. You say "here's the code", but I can't see it.

I am fairly familiar with photoshop...I'm sure I can make it myself, but I've been searching all over the web for some HTML that I can insert and most of them are designed for websites. I did find one however, but it is ugly and doesn't countdown unless I refresh.

Cheers.

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
Guest
Jul 09, 2008 Jul 09, 2008
Here's the code to have double figures in the clock. I'll add the code to make the text change color later, just explain more on how to you want it.

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 ,
Jul 10, 2008 Jul 10, 2008
I'd managed to get the clock figures working last night myself the same way you have so must be learning something. At the minute I've used a blue blackground selected from the stages properties, I need this to turn red when the timer reaches zero and remain red as it counts back up.
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
Guest
Jul 10, 2008 Jul 10, 2008
Well I'm not sure how you can change the actual background color using action script, but you can place a movie clip on the stage, expand it so it covers the whole stage (this can be done accurately using the align panel [Window > Align]), and change it's color to blue using the property inspector (so it starts off blue). Then you can change the color of the movie clip to red when the timer reaches 0. Look at the code below:

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 ,
Jul 10, 2008 Jul 10, 2008
Thats amzing. Thanks so much for your help. One last thing there isnt anyway i could make the colour transform any smoother like with a dissolve or a tween is there.
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
Guest
Jul 10, 2008 Jul 10, 2008
I'm not sure if there is a way to make a shape tween using action script (where the blue fades to red), but alternatively what you could do is inside the bg_mc movie clip (the blue movie clip that is going to transform to red when the timer reaches zero) you could add a motion tween. So, inside bg_mc, add a shape tween (frame one should have a simple blue square, then go to frame 5 [or whatever frame you feel is good] and add another key frame. Then, change the color of the square on this frame to red. Right click anywhere in between the two frames and select "Create Shape Tween" from the contextual window that appears. You can modify the shape tween in the properties inspector if you like). Make sure you add stop actions to the beginning and end of the shape tween so it doesn't repeat or anything. Than, change the code on line 41 in the countDown function (bg_mc.transform.colorTransform = red;) to bg_mc.play();. you could also make the shape tween take several seconds and make it start before it actually reaches zero seconds (i.e, if (minutes == 0 && seconds == 10) { bg_mc.play(); }). Then you'll just have to make the shape tween the appropriate length (120 frames if the frame fate is 12fps so it changes red when it reaches zero seconds. If this sounds confusing or complicated then give me your email and I'll send you an example (.fla file) of what I mean. Here's the new code with the change I mentioned:

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
Guest
Jul 10, 2008 Jul 10, 2008
It actually looks much better if the fade starts at 10 seconds and finishes at 0 (going from blue to red). So you'll have to make your shape tween last 10 seconds (120 frames long if the fps is 12) and start at 10 seconds. So the code would now look like this (just a small change):

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 ,
Jul 12, 2008 Jul 12, 2008
I've tried to have a go at tweening myself but cant seem to get it working if you could send me a file to see where im going wrong that would be great. My email address is andrewm@frontline.org.uk
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
Guest
Jul 12, 2008 Jul 12, 2008
I'll send you an email as soon as I can, but I can't right now since by computer is buggy and slow and for some reason I can't log onto my hotmail account. I'll be getting a new Windows and hard drive today and send you the email after (the email will be from robert_komaromi@hotmail.com).
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 ,
Jul 16, 2008 Jul 16, 2008
See this cool mp3 xml player with visualization, playlist and skins. Fully customisable. Vector. http://flashden.net/item/mp3-xml-strongplayerstrong-with-visualization-and-skins-vectorised/11851
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