I need to make a Goal Thermometer work dynamically. I have made the symbols and all in Flash and now need to make it work.
All my experience in Flash has been “cell” animation (all Timeline - no ActionScript’n) but now my manager wants this goal thing to work for different departments to see on the intranet (after they login…)
How do I pass the value to the symbol [redbar] to make it grow?? I know I have to make some kind of percentage calculation like ([size=2]goal_achieved/total_goal)*100 which will be done in the HTML but how do I get value received into the SWF???[/size]
sorry but AS confuses me (I’m just a lowly pixel monkey)
The reason it loops is because it uses a simple gotoAndStop(your percentage) command*. Obviously, there is no frame 80.7 and so the animation continues to play as it frantically searches for it. One solution would be to use Math.round on your data and display the closest frame, so change line 4 in frame 5 to read:
if (this.bar._currentframe == Math.round(_root.thermvalue)) {
It’s actually slightly more complicated than that. What it actually does is to play an animated tween until the current frame equals your percentage value, at which point the animation will stop. If you want to make it reflect your percentage more accurately, you will have to increase the size of the tween and perform some manipulation of the percentage to determine the new frame number. For example, to show 80.7%, you would have to make the tween 1000 frames long and then change the same line of code so that it plays the animated tween until the current frame equals your percentage value x 10 to land on frame 807.
There are two drawbacks with this approach:
because the tween is now 10 times longer, the animation will play 10 times more slowly and
it’s a moot point whether any viewers would discern any conceivable difference between 80.6, 80.7, 80.8 etc. given that each screen pixel is of a fixed size.
[quote=glosrfc;2328028]The reason it loops is because it uses a simple gotoAndStop(your percentage) command*. Obviously, there is no frame 80.7 and so the animation continues to play as it frantically searches for it. One solution would be to use Math.round on your data and display the closest frame, so change line 4 in frame 5 to read:
ActionScript Code:
[LEFT][COLOR=#0000FF]if[/COLOR] [COLOR=#000000]([/COLOR][COLOR=#0000FF]this[/COLOR].[COLOR=#000080]bar[/COLOR].[COLOR=#0000FF]_currentframe[/COLOR] == [COLOR=#0000FF]Math[/COLOR].[COLOR=#0000FF]round[/COLOR]COLOR=#000000[/COLOR][COLOR=#000000])[/COLOR] [COLOR=#000000]{[/COLOR]
[/LEFT]
It’s actually slightly more complicated than that. What it actually does is to play an animated tween until the current frame equals your percentage value, at which point the animation will stop. If you want to make it reflect your percentage more accurately, you will have to increase the size of the tween and perform some manipulation of the percentage to determine the new frame number. For example, to show 80.7%, you would have to make the tween 1000 frames long and then change the same line of code so that it plays the animated tween until the current frame equals your percentage value x 10 to land on frame 807.
There are two drawbacks with this approach:
because the tween is now 10 times longer, the animation will play 10 times more slowly and
it’s a moot point whether any viewers would discern any conceivable difference between 80.6, 80.7, 80.8 etc. given that each screen pixel is of a fixed size.[/quote]
Thanks so much for the help and it did work but I have taken into consideration regarding the drawback in doing it this way. It does take a long time.