开发者

AS2: Dynamic tween identifier

开发者 https://www.devze.com 2023-03-14 05:06 出处:网络
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:

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, 开发者_JS百科circle.current._y, Stage.height/2, 2, true);

Cheers


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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号