Dynamic Numbers

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

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

 
_global.ply = true; 

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

 
_global.ply = false;

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

 
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;
	 }
}
 

:slight_smile:

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

– Isis

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

yea…like a preloader…only different…

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

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

 
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:

 
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:

:slight_smile:

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

my pleasure :wink: