# Dynamic Numbers

**URL:** <https://forum.kirupa.com/t/dynamic-numbers/117829>\
**Category:** Uncategorized\
**Created:** [July 30, 2004, 5:34pm UTC](https://forum.kirupa.com/t/dynamic-numbers/117829 "2004-07-30T17:34:25Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Isis](https://avatars.discourse-cdn.com/v4/letter/i/85f322/32.png) [@Isis](https://forum.kirupa.com/u/Isis)\
**Post date:** [July 30, 2004, 5:34pm UTC](https://forum.kirupa.com/t/dynamic-numbers/117829/1 "2004-07-30T17:34:25Z")

</div>

I’ve created a simple bar graph, and I’ve tweened the graph to change values to new data. At the top of each bar, I have the actual number value for that bar, like my math professor told me to label my graphs back in HS.

Here’s what I want to do. I want to make that number change to the new value by cycling through numbers as the bar increases or decreases. It doesn’t have to be true data, just the graphical effect of the number value changing, and it has to stop when the bar graph tween stops.

I took a look at the cycling number tut on Kirupa, and it does the effect I want, but since it’s random in time, The numbers won’t always stop when the bar is done loading. Anyone have a better solution than this?? Like maybe linking the Bar’s coordinate values to the dynamic text? Any help would be great.

–Isis

---

<div class="post-metadata">

**Author:** ![ViNc3](https://avatars.discourse-cdn.com/v4/letter/v/b487fb/32.png) [@ViNc3](https://forum.kirupa.com/u/ViNc3)\
**Post date:** [July 31, 2004, 2:05am UTC](https://forum.kirupa.com/t/dynamic-numbers/117829/2 "2004-07-31T02:05:32Z")

</div>

on the first frame of your animtation you have this code:

```php
 
_global.ply = true; 

```

on the last frame of your animation you have this code:

```php
 
_global.ply = false;

```

Convert your dynamic text into a movie clip and enter the Var: figure1  
Then add this code to your movie clip:

```php
 
onClipEvent (load) {
	 times = 10;
	 //the highest number you want the number to random to
	 final_amount = 10;
	 //the final figure of your graph
}
onClipEvent (enterFrame) {
	 if (_global.ply == true) {
		 figure1 = Math.round(Math.random()*times);
	 } else if (_global.ply == false) {
		 figure1 = final_amount;
	 }
}
 

```

🙂

---

<div class="post-metadata">

**Author:** ![Isis](https://avatars.discourse-cdn.com/v4/letter/i/85f322/32.png) [@Isis](https://forum.kirupa.com/u/Isis)\
**Post date:** [August 2, 2004, 8:05pm UTC](https://forum.kirupa.com/t/dynamic-numbers/117829/3 "2004-08-02T20:05:59Z")

</div>

Cool thanks, I’ll try this later today when I have a free moment.

– Isis

---

<div class="post-metadata">

**Author:** ![Jeff\_Wheeler](https://avatars.discourse-cdn.com/v4/letter/j/59ef9b/32.png) [@Jeff\_Wheeler](https://forum.kirupa.com/u/Jeff_Wheeler)\
**Post date:** [August 2, 2004, 8:08pm UTC](https://forum.kirupa.com/t/dynamic-numbers/117829/4 "2004-08-02T20:08:29Z")

</div>

I would use the height of the bar to figure it out, simply mutiply by 1/maximum to get what your number should be… or something like that, but you get the point

---

<div class="post-metadata">

**Author:** ![ViNc3](https://avatars.discourse-cdn.com/v4/letter/v/b487fb/32.png) [@ViNc3](https://forum.kirupa.com/u/ViNc3)\
**Post date:** [August 3, 2004, 6:22am UTC](https://forum.kirupa.com/t/dynamic-numbers/117829/5 "2004-08-03T06:22:03Z")

</div>

yea…like a preloader…only different…

---

<div class="post-metadata">

**Author:** ![Isis](https://avatars.discourse-cdn.com/v4/letter/i/85f322/32.png) [@Isis](https://forum.kirupa.com/u/Isis)\
**Post date:** [August 3, 2004, 11:58pm UTC](https://forum.kirupa.com/t/dynamic-numbers/117829/6 "2004-08-03T23:58:22Z")

</div>

Sorry guys, I’m still a n00b at the scripting. I get the idea of what your suggesting, but I wouldn’t know where to begin with writing the script.

I think this would make more sense, while your script works for me Vince, I need to change the value a few times, as the graph changes more than once. So if the number was relational to the hight of the bar, that would be perfect.

Could you give me some starter code that I can reverse-engineer, or should I just go tear into my preloader bar?

Thanks again.  
–Isis

---

<div class="post-metadata">

**Author:** ![ViNc3](https://avatars.discourse-cdn.com/v4/letter/v/b487fb/32.png) [@ViNc3](https://forum.kirupa.com/u/ViNc3)\
**Post date:** [August 4, 2004, 8:42am UTC](https://forum.kirupa.com/t/dynamic-numbers/117829/7 "2004-08-04T08:42:36Z")

</div>

you could have your dynamic text showing the actual hight of your bar by putting this code on a movie clip which has the dynamic text in it with the Var: fig1

```php
 
onClipEvent (enterFrame) {
	fig1 = Math.round(_root.yourBar._height)
}

```

if you have to alter your figure (eg: your bar is taller than the value needed) you can always minus or plus:

```php
 
onClipEvent (enterFrame) {
	fig1 = Math.round(_root.yourBar._height + 10)
}

```

Of course you will always have to watch the height of your bar to make sure it works the way you want it to…try experimenting

PS: I hope my code is right :sigh:

🙂

---

<div class="post-metadata">

**Author:** ![Isis](https://avatars.discourse-cdn.com/v4/letter/i/85f322/32.png) [@Isis](https://forum.kirupa.com/u/Isis)\
**Post date:** [August 4, 2004, 6:03pm UTC](https://forum.kirupa.com/t/dynamic-numbers/117829/8 "2004-08-04T18:03:02Z")

</div>

Cool, works like a charm. had to devide by 12 to adjust for the proper values, but it looks just how I wanted it to. Thanks a ton Vince!

–Isis

---

<div class="post-metadata">

**Author:** ![ViNc3](https://avatars.discourse-cdn.com/v4/letter/v/b487fb/32.png) [@ViNc3](https://forum.kirupa.com/u/ViNc3)\
**Post date:** [August 5, 2004, 6:16am UTC](https://forum.kirupa.com/t/dynamic-numbers/117829/9 "2004-08-05T06:16:47Z")

</div>

my pleasure 😉
