Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 05-25-2012, 09:46 PM   #1
JadeNorth
Registered User
 
Join Date: May 2012
Posts: 8
Default How can I make a timer (Not a countdown)

Hello, I would like to make a timer to display how long you've been on the website. I've looked around but could only find mostly countdowns instead of countups. Can someone please help me with this? (P.S. I am a total noob at actionscript)

Thanks!
JadeNorth is offline   Reply With Quote
Old 05-26-2012, 12:08 AM   #2
JadeNorth
Registered User
 
Join Date: May 2012
Posts: 8
Default

An example would be the timer on nyan.cat (website)where it tells you how long you've nyaned, rather than a timer like this widgetbox. com/widget/countuptimer
JadeNorth is offline   Reply With Quote
Old 05-26-2012, 12:16 AM   #3
Prid
Prid - Outing
 
Prid's Avatar
 
Join Date: Oct 2009
Location: Halden, Norway
Posts: 1,191
Send a message via MSN to Prid Send a message via Skype™ to Prid
Default

ActionScript Code:
time = 0; function countUp(){     time++; } setInterval(time, 1000);

or more accurate:

ActionScript Code:
startTime = getTimer(); onEnterFrame = function(){     time = (getTimer()-startTime)/1000; }
__________________
I have returned, and am now 18
Prid is offline   Reply With Quote
Old 05-26-2012, 12:41 AM   #4
JadeNorth
Registered User
 
Join Date: May 2012
Posts: 8
Default

Um, where do i put that code?
JadeNorth is offline   Reply With Quote
Old 05-26-2012, 10:56 AM   #5
Prid
Prid - Outing
 
Prid's Avatar
 
Join Date: Oct 2009
Location: Halden, Norway
Posts: 1,191
Send a message via MSN to Prid Send a message via Skype™ to Prid
Default

On your Frame (click on Frame, press F9, paste code), but if you want the countup to show in a textfield, then use the Text Tool (T), open Properties Panel [CTRL+F3], and change Static Text to Dynamic Text. Create a textfield, select it, open Properties Panel [CTRL+F3] again, and under Var(iable Name), type, count_txt. Then, use this code on your Frame:

ActionScript Code:
startTime = getTimer(); onEnterFrame = function(){     count_txt = Math.floor((getTimer()-startTime)/1000); }
__________________
I have returned, and am now 18
Prid is offline   Reply With Quote
Old 05-28-2012, 12:59 AM   #6
JadeNorth
Registered User
 
Join Date: May 2012
Posts: 8
Default

For the text box thing, it tells me there's an error in the 5th line and if i continue exporting it just says "_level0.count_text" in the text box
JadeNorth is offline   Reply With Quote
Old 05-28-2012, 11:31 AM   #7
Prid
Prid - Outing
 
Prid's Avatar
 
Join Date: Oct 2009
Location: Halden, Norway
Posts: 1,191
Send a message via MSN to Prid Send a message via Skype™ to Prid
Default

Don't know why you're getting an error, but you named your textbox, count_tExt, whereas I told you to name it, count_txt, without E, but it doesn't really matter, as long as you change it to count_text in the script as well
__________________
I have returned, and am now 18
Prid is offline   Reply With Quote
Old 05-28-2012, 10:22 PM   #8
JadeNorth
Registered User
 
Join Date: May 2012
Posts: 8
Default

I did name it count_txt, and that's what it said in the box, just a typo when I put it on here. I wonder why it's not working?
JadeNorth is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump


All times are GMT. The time now is 08:35 AM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.