# Dynamic Variable Names

**URL:** <https://forum.kirupa.com/t/dynamic-variable-names/190449>\
**Category:** flash\
**Created:** [June 12, 2006, 12:14am UTC](https://forum.kirupa.com/t/dynamic-variable-names/190449 "2006-06-12T00:14:50Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![B\_L\_U\_E](https://avatars.discourse-cdn.com/v4/letter/b/ba8739/32.png) [@B\_L\_U\_E](https://forum.kirupa.com/u/B_L_U_E)\
**Post date:** [June 12, 2006, 12:14am UTC](https://forum.kirupa.com/t/dynamic-variable-names/190449/1 "2006-06-12T00:14:50Z")

</div>

I have the following code  
[AS]si = setInterval(function () {  
ind++;  
ind\>7 ? clearInterval(si) : null;  
var tw = new Tween(\_root.\_mc[“a”+ind], “\_xscale”, Regular.easeOut, 0, 200, 60);  
new Tween(\_root.\_mc[“a”+ind], “\_yscale”, Regular.easeOut, 0, 200, 60);  
tw.onMotionFinished = function() {  
new Tween(\_root.\_mc[“a”+ind], “\_xscale”, Regular.easeIn, 0, 100, 40);  
new Tween(\_root.\_mc[“a”+ind], “\_yscale”, Regular.easeIn, 0, 100, 40);  
};  
}, 50);  
[/AS]Basically, it goes through 7 loops and animates each object. My problem is that the onMotionFinished function isnt being triggered because it gets overwritten each time before it can. is there a way to dynamically create a variable name to keep track of each Tween? Something like [AS]var eval(“tw” + ind) = new Tween(\_root.\_mc[“a”+ind], “\_xscale”, Regular.easeOut, 0, 200, 60);  
eval(“tw” + ind).onMotionFinished = function() {[/AS]except eval appears to only work for objects. Any ideas? 🙂
