How To Create a “LIVE” Count-Up
Introduction
I have gotten some great reviews for my latest tutorial “How To Create a “LIVE” Visitor Counter” and I have been requested by many to make a tutorial of my “Count Up” application featured here on my site. So I thought, why not! Let’s give them what they want. Isn’t that what freemiums are all about?
This tutorial requires, as my previous tutorials, nothing more than the basic knowledge of Flash and ActionScript. Some basic knowledge of FTP and HTML is also required, however this is mostly a copy and paste situation so if you don’t possess this knowledge I am sure you are able to follow this tutorial with flying colors anyways. It’s pretty straight forward and I believe anyone could read this and be able to create their own count-up. With a little bit of focus and bit of patience it should be all good. Let’s start.
Step 1
Just like in my previous tutorial, mentioned in the introduction, we need a background. To make it easy I have chosen to take the same background as in the Live Visitor Counter tutorial. But of course you can go ahead and create your very own background in whatever size or shape that you want it to have. For this one however I have once again chose the 200*38 size with two layers creating that depth effect. Here’s my flattened layer consisting of two layers:
![]()
Once again, when creating your own background and are using layers, to create the depth effect, make sure you separate the “on top” layers from the “background layers to be able to put the text in between.
Step 2
OK, we have our background. Time to setup our project in Flash. Open up a new project and make it in ActionScript2.0. First thing we’re going to do is to set the Document Properties so we get the right size and speed of the application. So, open up “Document Properties” (Ctrl+J) and set the width to 200 and the height to 38. Also change the FPS (frames per second) from 12 to 30. This is to make sure we get an even second for each second. Also set the background to black black (#000000) as it’s mostly much easier to see if you’ve made any mistakes in your aligning later on. Don’t forget to name your project. I have chosen to name it “Live Count-Up”. Now you should have something similar to this:

Step 3
It’s time to set up our layers for the project. Create 4 (four) new layers making it a total of 5 (five) layers. Name them, from the bottom up, “background”, “labels”, “textfields”, “shine” and “actions”. Your setup should now look something like this:

Step 4
The first layer to get some content is actually our “actions” layer. Open up “Actions” view by selecting the first frame of the “actions” layer and right click on it. Choose “Actions” at the bottom of the list. Now, input this:
this.onEnterFrame = function() {
var trueday:Date = new Date();
var trueYear = trueday.getFullYear();
var trueTime = trueday.getTime();var startDate:Date = new Date(2008,11,12);
var startTime = startDate.getTime();var timeLeft = trueTime – startTime;
var sec = Math.floor(timeLeft/1000);
var min = Math.floor(sec/60);
var hrs = Math.floor(min/60);
var days = Math.floor(hrs/24);sec = string(sec % 60);
if (sec.length < 2) {
sec = “0″ + sec;
}
min = string(min % 60);
if (min.length < 2) {
min = “0″ + min;
}
hrs = string(hrs % 24);
if (hrs.length < 2) {
hrs = “0″ + hrs;
}
days = string(days);var countup:String = days+ “:” + hrs + “:” + min + “:” + sec;
countprnt.text = countup;
}
Now you’re thinking. Wow, that’s a lot of code and he said it was to be basic. No worries. I will try and explain the basics of the code line by line so you know what it does.
Line 1
this.onEnterFrame = function() {
This line opens up our script each time we the cycle hits this frame. What it means is that everytime our flash movie enters his frame it executes the ActionScript.
Line 2
var trueday:Date = new Date();
This line creates a variable for us to store the current date. The updated date so to say.
Line 3
var trueYear = trueday.getFullYear();
This line stores the current year in a variable named trueYear.
Line 4
var trueTime = trueday.getTime();
This line stores the current time in a variable named trueTime.
Line 5
var startDate:Date = new Date(2008,11,12);
This line is the only one you have to pay close attention to really. This line stores the date that you want the counter to start it’s count-up from. Also, this line has some more explaining to do. The layout of the date within the parentecies is Year, Month, Date. But, one thing that is really important here is the months only goes to 11. Meaning December is 11. It is like this because the computer counts January as month number 0. This is important when you add your date here.
Line 6
var startTime = startDate.getTime();
This line stores the startDate’s time. Meaning if you have entered it it will also include it down to the second.
Line 7
var timeLeft = trueTime – startTime;
Here is the calculation that calculates how many days, hours, minutes and seconds has passed since the start.
Line 8
var sec = Math.floor(timeLeft/1000);
This line calculates the milliseconds into the number of seconds.
Line 9
var min = Math.floor(sec/60);
This line calculates the seconds into the number of minutes.
Line 10
var hrs = Math.floor(min/60);
This line calculates the minutes into the number of hours.
Line 11
var days = Math.floor(hrs/24);
This line calculates the hours into the number of days.
Line 12
sec = string(sec % 60);
This line calculates the total number of seconds that have passed.
Line 13
if (sec.length < 2) {
sec = “0″ + sec;
}
These lines adds a zero (0) in front of the seconds if the total number of seconds are less than 10. We do this to make sure we always have a two digit print out on our count-up.
Line 14
min = string(min % 60);
This line calculates the total number of minutes that have passed.
Line 15
if (min.length < 2) {
min = “0″ + min;
}
These lines adds a zero (0) in front of the minutes if the total number of minutes are less than 10. We do this to make sure we always have a two digit print out on our count-up. Just like in the seconds.
Line 16
hrs = string(hrs % 24);
This line calculates the total number of hours that have passed.
Line 17
if (hrs.length < 2) {
hrs = “0″ + hrs;
}
These lines ads a zero (0) in front of the hours if the total number of hours are less then 10. We do this to make sure we always have a two digit print out on our count-up. Just like in the seconds and the minutes.
Line 18
days = string(days);
This line stores the total number of days that have passed.
Line 19
var countup:String = days+ “:” + hrs + “:” + min + “:” + sec;
This line stores our print out in the right order. It combines all of our calculated variables and stitches it into one string variable ready for prin out.
Line 20
countprnt.text = countup;
This line prints our string to countprnt.text which will be our dynamic text field where we see our count-up progress.
Line 21
}
This line just closes our script.
Step 5
OK, now we’re done with the ActionScript. Time to add the visible’s to the counter. Let’s add the background. Choose “File -> Import -> Import To Stage…“. Pick your background and click ok. If all is ok it should align itself to your workspace. It should now look something like this:

Step 6
Our background is in place and we need to insert our labels. The labels that will tell the viewer what he/she is looking at. Let’s start with the title. Let’s add “SINCE LAUNCH” title to the count-up in the upper right corner in the first frame of the “labels” layer. I have chosen the font “Trebuchet MS” size 7 to make it clean and tidy. You can go ahead and use whatever font you feel fits your needs. Now we have something looking like this:

I have chosen not to add the bottom labels yet as we want to make sure first where they go. This we do by inserting the actual counter.
Step 7
Time to insert the core of the count-up. The count-up itself. In the first frame of the “textfields” layer let’s add a dynamic text field with the text “000:00:00:00″ indicating where the digits will go. I have chosen Arial as font and 18 as size. I also picked Bold to give it more body. I gave it a slight bright gray to make it stand out a bit from the titles pure white color.
Before we enter the next step we need to give our text field and instance name so that our ActionScript can push it’s data to it. So, click the newly created dynamic text field with out zeros in it and give it an instance name of “countprnt” which you will also find in our script. ALSO, make sure you widen the text field all the way to the left to give it more room for more digits.
IMPORTANT: Make sure you have right aligned the text in the dynamic text field so that the increment always looks the same. You should now have something looking like this:

Step 8
There. Now we can go ahead and add the last labels to the count-up as we have the guide now to align them. We’ll need to add 4 different static text fields to do this. Under the far right zero’s you type “SEC”, then “MIN”, “HRS” and “DAYS”. I have used the same font and size as in the title label. Same color and everything. You should now have something looking like this:

Step 9
That’s almost everything as far as our application. The only thing we need to do right now is to add the “shine” layer to it to create that extra depth to the count-up. Once again add the Shine image (which is a semi transparent layer saved as a PNG in Photoshop) by Importing it to the stage on the first frame of the “shine” layer. After doing this, if it’s not aligned already, align it by using the “Align X” commands found on your right in the Flash workspace.
Now we have something looking like this:

Step 10
Well, what do you know. Our count-up is done and what we need to do right now is to save it and publish it. So go ahead and save your newly created online application. Name it “Live Count-Up”. After saving it open up “Publish Settings…” and make sure that ActionScript is set to ActionScript2.0 and that JPEG quality is set to 100. Now go ahead and publish your new application. All your new files are now in the same folder and it’s time to dig through the HTML to find the flash object tags so we can add them to your site.
Step 11
Upload your new application flash movie to a directory of your choice on your server host, but make sure you remember the path to it. The shorter the better. The file you should upload is “Live Count-Up.swf”.
Step 12
After uploading your file to your server the only thing we need to do right now is to incorporate the object code to your website/blog. This is the code you should use. Place it anywhere on your web site’s html code and bang, there it is!
<object classid=”clsid:d27cdb6e-ae6d-11cf-96b8-444553540000″ codebase=”http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0″ width=”200″ height=”38″ id=”Live Count-Up” align=”middle”>
<param name=”allowScriptAccess” value=”sameDomain” />
<param name=”allowFullScreen” value=”false” />
<param name=”movie” value=”Live Count-Up.swf” />
<param name=”quality” value=”high” />
<param name=”bgcolor” value=”#000000″ />
<embed src=”Live Count-Up.swf” quality=”high” bgcolor=”#000000″ width=”200″ height=”38″ name=”Live Count-Up” align=”middle” allowScriptAccess=”sameDomain” allowFullScreen=”false” type=”application/x-shockwave-flash” pluginspage=”http://www.macromedia.com/go/getflashplayer” />
</object>
This code is looking for the flash movie in the root directory. If you put it in another directory just use “directory\Live Count-Up.swf” and it should all good.
That should be pretty much it! Now go ahead and test your new count-up on your own site or blog or you can check out this example to see how it works:
Round Up
Well, all should be working now there are plenty of areas this could be used within. For example you could stick one of these onto each and every post you make if you want to be sure everyone knows exactly how long ago you posted your blog post. Or, why not combine my “Live Visitor Counter” with this one to showcase your hit count during a certain amount of time. Should be pretty cool to watch for anyone!
Whatever you use this for it’s only your imagination that sets the limit. You are welcome to use this technology in whatever way you see fit. But, make sure of one thing. Have fun with it!
I hope you have enjoyed this tutorial and that you will check out my other tutorials on this site. I would very much like to see you return for future tutorials as well. Leave a comment or send me an email. If you have any questions don’t hesitate to contact me (which reminds me, I haven’t set up my contact page yet. Dang it! – 02/02/09).
It’s been great fun creating this tutorial and I hope I will hear from you soon!
Thank you!
Hey, Webmaster.
Can I use a photo from your blog?
Of course, i will place a link to source.
Thanks.
Yours Eremeeff
[Reply]
adapter keyboard Reply:
November 4th, 2011 at 1:36 am
sentences of service expressions in English. Every morning, you will find people, men and womenac adapter
[Reply]
Eremeef – Sure, no problem. What photo is it you’re going to use?
[Reply]
loved it. will give it a try, thanks.
just one thought what will happen when day 1000 comes?
[Reply]
MrStrider – Thank you! It will just keep on adding. The script is such that it creates it’s digit layout itself within the script and the 3 digit day representation was just for guidence. This script has now limits. So no worries.
[Reply]
Glad I found this site – I’m finding the content very useful – thanks!
[Reply]
[...] on this site that will enhance the feel of your website for your every visitor. Everything from Count-Up’s and Live Visitor Counter’s to Expansive XML Music [...]
really the code is very useful but why in flash version dont accepte double (“”) 1093: Syntax error.var countup:String = days+ “:” + hrs + “:” + min + “:” + sec;
but when i change to
countup:String = days+ ‘:’ + hrs + ‘:’ + min + ‘:’ + sec;
work nomally but given me a mains in the count down
[Reply]
khalld – What version of flash are you using. The code snippets in this tutorial are directly taken from my flash project so it should work as intended. However, what version of AS are you set on. This is AS2.0. Maybe ou’re using AS3.0.
[Reply]
first thanks for your replay i use as2 in as3 the code not work you can try yourself
[Reply]
Thank’s Twinster you have nice tutorial’s, also great design of minervity.com. Keep working.
Greetings
Ljuba
[Reply]
Gut!
[Reply]
Great tutorial… I’m trying to make a money donated counter that would count up (for example $0.23 every second). How would I go about changing this counter to one that would display in dollar value?
Thanks for your help in advance.
[Reply]
This is great, but how do you add milliseconds to the counter?
I’m quite the novice and tried to fumble with the code, but in the last three zeroes (000:00:00:00:000) keeps appearing “NaN” ?? also adding two zeroes in front of the days is proving quite difficult.
i tried
this.onEnterFrame = function() {
var trueday:Date = new Date();
var trueYear = trueday.getFullYear();
var trueTime = trueday.getTime();
var startDate:Date = new Date(2009,5,13,16,00);
var startTime = startDate.getTime();
var timeLeft = trueTime – startTime;
var sec = Math.floor(timeLeft/1000);
var min = Math.floor(sec/60);
var hrs = Math.floor(min/60);
var days = Math.floor(hrs/24);
msec = string(msec % 1000);
if (msec.length < 3) {
msec = “0″ + msec;
}
sec = string(sec % 60);
if (sec.length < 2) {
sec = “0″ + sec;
}
min = string(min % 60);
if (min.length < 2) {
min = “0″ + min;
}
hrs = string(hrs % 24);
if (hrs.length < 2) {
hrs = “0″ + hrs;
}
days = string(days % 365);
if (days.length < 3) {
days = “0″ + days;
var countup:String = days+ “:” + hrs + “:” + min + “:” + sec + “:” + msec;
countprnt.text = countup;
}
but obviously the msec part is incorrect, and also the stuff i added to days seems faulty
if you could clear this up it would be greatly appreciated. (unless you tell me it’s too hard or impossible, in wich case i thank you for your time)
greetings
tom
[Reply]
Alright, I can’t make this work.
I’m using Flash CS3 and I’ve stripped it down to the bare minimum (action layer, and dynamic text field layer)to see if maybe I was doing something wrong in another layer but in the end I just end up with an swf that stays at zero.
I’ve placed the actionscript exactly as it appears here, once without editing anything and another with the date I’m looking to use, but no results.
The actionscript is giving me some “Compiler Errors” in lines 7 and 10. I don’t know if that may have something to do with the fact that it wont work.
Any help would be much appreciated.
[Reply]
This is awesome! One question…is there a way to control the date using an external TXT file? I have my countup working, but a client wants to change the date depending on the l-ast work incident.
[Reply]
Strange, I get the following error. I have double-checked that my source matches your 5 times now. Code is the exact same.
**Error** Scene=Scene 1, layer=actions, frame=1:Line 10: Syntax error.
var timeLeft = trueTime – startTime;
Total ActionScript Errors: 1 Reported Errors: 1
Any ideas?
[Reply]
How can I change this to billions, millions, thousands, etc…. instead of days, hours, min, sec?
Txs
[Reply]
If you are willing to buy real estate, you will have to get the home loans. Furthermore, my mother all the time utilizes a car loan, which occurs to be the most fast.
[Reply]
I get the following error. I have double-checked that my source matches your 5 times now. Code is the exact same.
**Error** Scene=Scene 1, layer=actions, frame=1:Line 10: Syntax error.
var timeLeft = trueTime – startTime;
Total ActionScript Errors: 1 Reported Errors: 1
[Reply]
var timeLeft = trueTime – startTime;
change to.
var timeLeft = startTime – trueTime;
[Reply]
Discount Wholesale Electronics, Wholesale Cell Phones, Electronic Gadgets and More from the Best Dropship Wholesaler
[Reply]
hey,you have posted such a effectful article that it will certainly help me
[Reply]
Thank you for providing good information,Wholesale Electronics and Wholesale Gadgets from pickegg.com,Pickegg.com is an online Wholesale Electronics store. Offers consumer electronics and electronic gadgets at best price
[Reply]
One day we wil like this
[Reply]
The Fundamental Crafts Skills Using IPadiPhone Cases
[Reply]
I enjoy reading the report, too. It′s easy to understand that a journey like this is the biggest event in ones life.
xiaoxiao123 09 13
[Reply]
I tried to think so, but i found it was not as the same in the actual process. As you mentioned, I still have doubts, but really thank you for sharing!
[Reply]
This was a useful post and I think it is rather easy to see from the other comments as well that this post is well written and useful.
[Reply]
Wonderful blog, it’s really useful, I like it, thanks for your post. I want to share you with my favorite batteries like Compaq Evo N400c Battery, Hope you will like them.
[Reply]
If you are a real NFL fan, authentic NFL jerseys could be the best option for you to show how big fan you are. There are also many autographed jerseys available in the market today. However, you should know the right tricks and techniques to find the best ones. Although there are premier and replica, jerseys available in the market today, most of them are not able to keep up the quality and finishing of the genuine NFL jerseys. Authentic jerseys that will feature your favourite Authentic nfl jerseys player or team could be the best option for you to make a special appearance in the crowd.
[Reply]
After high school Archie enrolled at Ole Miss in Oxford, Mississippi which is a little less than 100 miles northeast of his hometown in the city of Drew. While at Ole Miss the 6’3″ right handed passer served as the starting quarterback for the Rebels for two seasons in 1969 and 1970. In his prime time debut in 1969 in the early days of college football games being nationally televised Archie had a career day in a one point loss to the University of Alabama. In a losing effort Archie racked up 540 yards of offense (104 yards rushing and 436 yards passing) in front of a national television audience. Through the 2009 football season the high water mark that Archie established Brian Urlacher Jersey for total yards by one player still sits atop the Southeastern Conference (SEC) record books for the most yards put up by a single player in one game.
[Reply]
This was a useful post and I think it is rather easy to see from the other comments as well that this post is well written and useful.
[Reply]
Thank you for providing good information,Wholesale Electronics and Wholesale Gadgets from pickegg.com,Pickegg.com is an online Wholesale Electronics store. Offers consumer electronics and electronic gadgets at best price.
[Reply]
Perseverance.Non-hero than the Yellow River.
[Reply]
购物商家导航
购物商家导航
[Reply]
look forward more posts
welcome to our web!
jordans
[Reply]
Great. Now i can say thank you!just love your post!
[Reply]
Best deals on optical transceivers. Buy SFP Plus, SFP+, X2, XENPAK, XFP, SFP, GBIC for Cisco,HP and 3Com with lowest prices and lifetime warranty. http://www.sfplustransceiver.com/cisco-ws-g5487 WS-G5487
[Reply]
If you think black iphone 4 is a little dull, it’s your time to change it to a more delicate color. Let’s get the iphone 4 white!
[Reply]
Take the latest iphone 4 white Conversion Kit and start to change a new look to your favorite iphone 4 now! You can sure love it!
[Reply]
Many thanks to the person who made this post, this was very informative for me. Please continue this awesome work. Sincerely…
[Reply]
Coach fans will be happy.Today we will recommend Coach bags 2011 new styles for you! In this new year,Coach bags are designed towards a more luxurious style! Besides the delicate design, all Coach bags also have enough capacity,lightsome moulding, practical-use and other functions.The perfect bag is full of everything,all is suitable for the latest popular fashion modelling,snap up quickly!
Choose the gorgeous color and eye-catching Coach handbags, is the best choice to build popular styles! Now Coach bags sale on our online Coach outlet http://www.coachbagsonlines.com/ has many kinds of Coach cheap bags.These products are all in different color and style can easy to match your clothes.I think you will not never regret to have these Coach outlet bags in your closet.
We guarantee that our Coach bag outlet are able to provide the bags of Coach for cheap and best service for you.You should believe that our Coach bags online are Coach factory outlet.Don’t miss this choice!
[Reply]
http://www.google.com.hk/search?hl=zh-CN&newwindow=1&safe=strict&rlz=1B3MOZA_zh-CNCN372CN372&q=Leave+a+comment!+site%3Awww.minervity.com&btnG=Google+%E6%90%9C%E7%B4%A2&aq=f&aqi=&aql=&oq=
[Reply]
Coast dresses of 2011 summer full of vitality and color. This is your wardrobe an instant update of all those signals through the main trends for the coming occassion dresses 2011. From the luxurious fabrics, these basic essential pieces of the season will be a treasure you will relive for years. Coast dress into a modern urban women . Cheap coast clothing on sale, which is well known for their style and synchronized with the latest fashion trends.
[Reply]
http://www.botteshugg.com/ugg-ultra-tall-bottes-5245-noir-p-369.html
[Reply]
Coach fans will be happy.Today we will recommend Coach bags 2011 new styles for you! In this new year,Coach bags are designed towards a more luxurious style! Besides the delicate design, all Coach bags also have enough capacity,lightsome moulding, practical-use and other functions.The perfect bag is full of everything,all is suitable for the latest popular fashion modelling,snap up quickly!
[Reply]
へようこそ。当社は2004年に設立され、2006年にインターネットマーケティング事業にコミットされました。 の大きな需要が常にあり、よく販売している。最近、我々はいくつかの新しいsac à mainして、当社のウェブサイト上でそれらを更新。ここでは見つけることができるいくつかの稀少ある、他のウェブサイトから見つけることは困難れた。NBAジャージはhotsaleで常にもです。
私たちは、お客様から多くの偉大なコメントを得て、外国のmakertsで良い評判を獲得している、90%以上のお客様は今すぐオンラインメンバーが80,000を超えてまで、当社の製品およびサービスに満足しています。今の時点で、我々は現在、18カ国以上から顧客にサービスを提供し、そして我々はまだ成長している。私たちは本当に世界中から個人や企業との協力を通じて事業拡大を願っています。—ercai
[Reply]
Thank you for sharing this information. The information was very helpful and save of my time.
[Reply]
Discover a world of fashion Swarovski Crystal at hermes birkin. Their mission is to provide stunning and designer Swarovski Crystals.hermes birkin shall ship the items via DHL or EMS in 12-48 hours once your payment is cleared, and your parcels usually arrive in the next 3-7 business days. If for any dissatisfied reasons, you can request for an exchange or refund within 14 days upon receipt of the order in a resalable condition.
[Reply]
Thank you for taking the time to publish this information very useful!I’m still waiting for some interesting thoughts from your side in your next post thanks These articles written too great,they rich contents ma le scarpe non ti donano. meglio dei sandali con stringe più sottili e caviglia libera Perfect! and data accurately.they are help to me.I expect to see your new share.
[Reply]
Whatever you do, work hard as long as there is no unsuccessful.
[Reply]
http://www.sfpex.com/sfp+ sfp+
Order fiber optic transceiver from SFPEX – the leading manufacturer of optical transceiver such as SFP, SFP+, XFP, X2, XENPAK, GBIC, BIDI, CWDM, DWDM.
[Reply]
They have many quilted barbour jackets . And for men we have found barbour jacket that will offer comfort and practicality whilst remaining looking polished.
[Reply]
Leave a comment!
Friends & Partners
10 Steps
Abduzeedo
Andy Sowards
BittBox
Brian Cray
Colorburned
CrazyLeaf Design
Design Bump
DesignFalvr
Design Reviver
Design Shard
Design Your Way
Digigirl
From The Couch
Fudge Graphics
Fuel Your Creativity
GoMediaZine
Good-Tutorials
Hongkiat
I Am Khayyam
ImJustCreative
InstantShift
Just Creative Design
Krftd
Line25
Loon Design
Mashable
MyInkBlog
Naldz Graphics
Noupe
Obox Design
Outlaw Design Blog
PhotoshopGirl
Photoshop Roadmap
Printed Proof
PSD Fan
PSDTuts+
Six Revisions
Smashing Magazine
Speckyboy
Spoon Graphics
Spoonfed Design
The Design Superhero
Tutorial9
Tutorial King
Tutorial Magazine
TutZone
Vandelay Design
VectorTuts+
Webdesigner Depot
Web Design Ledger
We Are Not Freelancers
Random Posts
Latest Video Post
Recent Posts
Most Commented
Most Popular