# Switch simple count up to count down

**URL:** <https://forum.kirupa.com/t/switch-simple-count-up-to-count-down/218777>\
**Category:** flash\
**Created:** [March 10, 2007, 10:09pm UTC](https://forum.kirupa.com/t/switch-simple-count-up-to-count-down/218777 "2007-03-10T22:09:59Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![dave\_lantto](https://avatars.discourse-cdn.com/v4/letter/d/fbc32d/32.png) [@dave\_lantto](https://forum.kirupa.com/u/dave_lantto)\
**Post date:** [March 10, 2007, 10:09pm UTC](https://forum.kirupa.com/t/switch-simple-count-up-to-count-down/218777/1 "2007-03-10T22:09:59Z")

</div>

Hello…first post for me after finding a lot of great info here.

I’ve found a simple count up script over on [Actionscript.org](http://Actionscript.org)

[COLOR=#993300]var[/COLOR] count:[COLOR=#993300]Number[/COLOR] = [COLOR=#000000]0[/COLOR];  
[COLOR=#993300]var[/COLOR] maxNum:[COLOR=#993300]Number[/COLOR] = [COLOR=#000000]1250[/COLOR];  
[COLOR=#993300]var[/COLOR] num:[COLOR=#993300]Number[/COLOR] = [COLOR=#000000]1[/COLOR];  
[COLOR=#993300]this[/COLOR].[COLOR=#993300]createTextField[/COLOR][COLOR=#000000]([/COLOR][COLOR=#0000ff]“txt”[/COLOR], [COLOR=#993300]this[/COLOR].[COLOR=#993300]getNextHighestDepth[/COLOR]COLOR=#000000[/COLOR], [COLOR=#000000]0[/COLOR], [COLOR=#000000]0[/COLOR], [COLOR=#000000]100[/COLOR], [COLOR=#000000]50[/COLOR][COLOR=#000000])[/COLOR];  
[COLOR=#993300]onEnterFrame[/COLOR] = [COLOR=#993300]function[/COLOR] COLOR=#000000[/COLOR] [COLOR=#000000]{[/COLOR]  
count += num;  
[COLOR=#993300]if[/COLOR] [COLOR=#000000]([/COLOR]count \>= maxNum[COLOR=#000000])[/COLOR] [COLOR=#000000]{[/COLOR]  
num = [COLOR=#000000]0[/COLOR];  
txt.[COLOR=#993300]text[/COLOR] = [COLOR=#0000ff]“125.0”[/COLOR];  
[COLOR=#000000]}[/COLOR] [COLOR=#993300]else[/COLOR] [COLOR=#000000]{[/COLOR]  
[COLOR=#993300]var[/COLOR] v = count / [COLOR=#000000]([/COLOR]maxNum / [COLOR=#000000]125[/COLOR][COLOR=#000000])[/COLOR];  
txt.[COLOR=#993300]text[/COLOR] = v;

[COLOR=#993300]var[/COLOR] str = [COLOR=#993300]String[/COLOR]COLOR=#000000[/COLOR];  
[COLOR=#993300]var[/COLOR] io = str.[COLOR=#993300]indexOf[/COLOR]COLOR=#000000[/COLOR];  
[COLOR=#993300]if[/COLOR] [COLOR=#000000]([/COLOR]io == -[COLOR=#000000]1[/COLOR][COLOR=#000000])[/COLOR]  
[COLOR=#000000]{[/COLOR]  
txt.[COLOR=#993300]text[/COLOR] = v + [COLOR=#0000ff]’.0’[/COLOR];  
[COLOR=#000000]}[/COLOR]  
[COLOR=#000000]}[/COLOR]  
[COLOR=#000000]}[/COLOR]

[COLOR=#000000]This works great for my use, but now I am trying to figure out how to make it count down. I’ve tried changing everything to opposites like count=1250 and maxNum=0 (I think this would be the minNum instead), count+=num to count-=num, and count\>=maxNum to count\<=maxNum. But I’m stuck…any ideas? I’ll search through the forum to see if I can find any info, but if anyone has a answer, that would be great. Thank you very much![/COLOR]
