I’m working with the Tween class in Flash 8. It’s great stuff, except I find my ActionScript is getting excessively lengthy. For example, I have ten instances of buttons on stage. They all utilize this particular bit of code, which makes the buttons pop upward:
ActionScript Code:
[FONT=Courier New][LEFT]button1.[COLOR=#0000FF]onRollOver[/COLOR]=[COLOR=#000000]**function**[/COLOR][COLOR=#000000]([/COLOR][COLOR=#000000])[/COLOR][COLOR=#000000]{[/COLOR]
[COLOR=#808080]//initailizing the Tween[/COLOR]
[COLOR=#000000]var[/COLOR] popBtn:Tween=[COLOR=#000000]new[/COLOR] Tween[COLOR=#000000]([/COLOR]button1, [COLOR=#FF0000]"_y"[/COLOR], mx.[COLOR=#000080]transitions[/COLOR].[COLOR=#000080]easing[/COLOR].[COLOR=#000080]Elastic[/COLOR].[COLOR=#000080]easeOut[/COLOR], [COLOR=#000080]0[/COLOR], -[COLOR=#000080]20[/COLOR], [COLOR=#000080]2[/COLOR], [COLOR=#000000]true[/COLOR][COLOR=#000000])[/COLOR];
[COLOR=#808080]//calling the tween object[/COLOR]
popBtn.[COLOR=#0000FF]start[/COLOR]COLOR=#000000[/COLOR];
[COLOR=#000000]}[/COLOR]
[/LEFT]
[/FONT]
The only difference for any of the buttons in the script is the name of the instance. When i set this up as a global function, using “this” instead of a specific instance name, the script fails to execute. So I have to hammer out all those lines of code for each button instance.
Thanks in advance for any help!