1
votes

How do i go about setting the tween identifier dynamically. I have tried eval but it says I need a variable on the left of the assignment operator. here's what I tried:

eval ("TweenAX" + circle.current.arrowHead.count) = new Tween(circle.current.arrowHead, "_x", mx.transitions.easing.Strong.easeOut, circle.current._x, Stage.width/2, 2, true);
eval ("TweenAY" + circle.current.arrowHead.count) = new Tween(circle.current.arrowHead, "_y", mx.transitions.easing.Strong.easeOut, circle.current._y, Stage.height/2, 2, true);

Cheers

1
Not an answer, but I suggest to have a look at tweener which makes tweening much mor comfortable.DanielB
Hmmm...I don't like eval much. You could have an array or associative array to store your tweens. eval or not, there's always the hacky way of accessing your variables through _root. But, as @Daniel mentioned, try a better tweening library. Tweener or TweenLite are faster, lighter and easier to use than the default mx.transitions.Tween classGeorge Profenza

1 Answers

1
votes

I'm not 100% sure I understand what you are trying to achieve, but I think you're looking for the bracket syntax:

this["TweenAX" + circle.current.arrowHead.count] = new Tween(circle.current.arrowHead, "_x", mx.transitions.easing.Strong.easeOut, circle.current._x, Stage.width/2, 2, true);
this["TweenAY" + circle.current.arrowHead.count] = new Tween(circle.current.arrowHead, "_y", mx.transitions.easing.Strong.easeOut, circle.current._y, Stage.height/2, 2, true);

This will create two properties on this named TweenAXN and TweenAYN where N is the value of circle.current.arrowHead.count