Nothing new but I thought I’d post it up here just in case anyone wanted it – it’s a very basic spin-to-number counter – useful as a counter to show how many hits you’ve had or how many people have linked to your post etc.
Here’s what it looks like:
[flash src=”/minilinks/files/counter.swf” width=”302″ height=”68″ flashvars=”num:123456″ /](View/download .swf here: http://mj7.co.uk/am1y)
To change the number just use a flashVar (or add a variable) called “num” and give it a number up to 7 digits – you can leave off the leading zeros as these will be added in automatically. So for example use:
<param name=”flashVars” value=”num=1234567″ />
You can download the FLA (I backsaved it to CS3) here: http://mj7.co.uk/am12
(NOTE: this .FLA uses mctween2 extension – you can download it here: mctween)
I’d love you to either use this as is – or even better – improve it and send it back.
If you do use it please give me a nod – if you like it enough to use it then why not share it?
UPDATE:
I had an email from someone who wanted to increase the amount of digits that show in the counter – I quickly sent him an updated version but he asked if I could give an overview of the steps I took so he could add/remove more in the future – so Raymond – this is for you!
To add more digits do the following:
Open the FLA and double click the counter to edit it – you should be able to select each digit separately now. To add more just select the digit on the far left (yes left not right) and copy it – then press CTRL+SHIFT+V to paste it in place and then use your cursors to move it to the far left (yes left – we add new digits to the left). Rename this d8 (It should have copied the instance name from the previous which was d7) – repeat this as required renaming to d9, d10, d11 etc. In the end you should have a row of digits named “d+instance number” DESCENDING – e.g. d10,d9,d8,d7,d6,d5,d4,d3,d2,d1. OK that part is done – now for the actionscript.
To update the AS view the code on Frame 1 – we’ll set the digit limit to a variable for easy updates in the future. Change line 4 (number = (_root.num!=undefined) ? _root.num.toString() : ‘1234567’;) to have the value ‘1234567890’ – or whatever you want the default counter number to be. Then under this line add a new line with this code on:
totalNums = 10; // set the value of this to the amount of digits you want to display
Then on lines 13, 15 (this is only a comment though) and 22 change the integer 7 to the variable totalNums.
Finally change the stage size to fit your new counter.
Save and preview.
To Remove Digits:
Just delete the digits from the LEFT and follow the same actionscript amends as above changing the totalNums to the amount of digits required.
…..
Job done. Any questions just shout.


Circularera
pardon me, I am very new user for this type of application. Do you mind if you can tell me how to get the access of editing the numbers?
mj7
You change the numbers when you embed the .sfw file into your HTML. It really depends on how you embed the Flash file into your page – if you use the standard object/embed method then you need to add the parameters: <param name=””flashVars”” value=””num=1234567″”> (in an embed tag) or flashVars=”num=1234567″ (in the object tag).
If you are using a Flash insertion script like swfobject then you would have to read the documentation for that script to find out how to add extra parameters – although swfobject will pick up the above two methods without issue.
Hope that helps
mona5
Hi MJ,
Thanks for the perfect work. I tried it and it is very usefull!
One question: if I want the counter to count a second and a third time. How can I edit it?
Here is an example what I mean:
first time: counter counts and stops with the numbers 1234567,
counter stops about 5 seconds and counts a second time, this time counter stops with the numbers 5555555.
And also a third time with different numbers..
Is is easy to edit it? I know only the basic about flash, and not too mutch about Action Script.
Thanks!
Mona
mj7
Mona. Thanks for the comment – you can achieve this by editing the Flash file directly, if you only want to use one predefined set of numbers, or you can trigger it via JavaScript so you can change the numbers more easily at any time (even randomly on page load). I can give you the code for either but I'd probably suggest the JavaScript approach is more versatile – did you want the code for that?
Majed_m9
Hi MJ
Is there any update to make work with as3?
mj7
I'm afraid I haven't got round to porting all my old scripts to AS3 yet – I find I am using Flash less and less now so it has not been a priority, sorry. I promise that when I do start porting over to AS3 I will start with this one and post it here as soon as it is ready – although that probably doesn't help your immediate needs.
Sorry!
Shem
Hi,
i got this problem under Firefox and Chrome that first (sometimes first and second) digit stays blured after counter stops.. I've tried to change animation times but that didn't help. Maybe You know how to solve this..?
First run is always good, but second (after refreshing) and after aren't.
Thanks in regards.
Shem
Chrome is ok, only Firefox got that error, so i suppose it could be flash plug-in…
Dimitri Vlaanderen
How to read and insert external numbers from a “txt”-file?
Anyone ?
Dimitri Vlaanderen
What was it, that you did to stop from turning? What player-setting did you use ?
siraj
How is using fla file ? not working still…
steph
Hi, i tried to copy the timeline and the existing elements in the library into my existing project timeline and library. It doesn't seem to work. Pls help. TQ
mj7
Just checking – have you installed the MCTween extension – http://hosted.zeh.com.br/mctwe… ? as the movie requires this to be installed using the extension manager. Also – this code (being quite old now) is AS2 so if your current movie is AS3 it will not work.
If you are running AS2 and have got MCTween installed then are you getting any messages in the output panel?
Cory
Awesome work, thanks so much! Updated directions were spot on and you saved me a great deal of time. Much obliged!
Cory
Is there a way to slow down the animation to keep it continuous? Something similar to Apple's countdown to 50 billion apps?