AS3 补间数组内的变量
AS3 Tween a variable inside an array
我有以下完美运行的代码:
updaterVariable = 0;
Tweener.addTween(this, {time:2, transition:"linear", updaterVariable:1000, onUpdate:tweenerUpdate});
我将在 2 秒内获得从 0 到 1000 补间的 updaterVariable 的值。我的问题是是否有类似的方法来补间数组中的变量,例如:
updaterVariable[10] = 0;
Tweener.addTween(this, {time:2, transition:"linear", updaterVariable[10]:1000, onUpdate:tweenerUpdate});
我试过上面的代码,但它不起作用。有人可以帮忙吗?
您可以将数组传递给 tweener 并使用索引作为要更改的字段:
updaterVariable[10] = 0;
Tweener.addTween(updaterVariable, {time:2, transition:"linear", '10':1000, onUpdate:tweenerUpdate});
不确定您使用的是哪种补间软件,但它适用于 TweenMax:
private var arr:Array;
public function Main() {
arr = [];
arr.push(0);
arr.push(0);
arr.push(t);
TweenMax.to(arr, 1000, { '2' : 1000 } );
addEventListener(Event.ENTER_FRAME, onframe);
}
private function onframe(e:Event):void {
trace(arr[2]);//outputs expected numbers
}
我有以下完美运行的代码:
updaterVariable = 0;
Tweener.addTween(this, {time:2, transition:"linear", updaterVariable:1000, onUpdate:tweenerUpdate});
我将在 2 秒内获得从 0 到 1000 补间的 updaterVariable 的值。我的问题是是否有类似的方法来补间数组中的变量,例如:
updaterVariable[10] = 0;
Tweener.addTween(this, {time:2, transition:"linear", updaterVariable[10]:1000, onUpdate:tweenerUpdate});
我试过上面的代码,但它不起作用。有人可以帮忙吗?
您可以将数组传递给 tweener 并使用索引作为要更改的字段:
updaterVariable[10] = 0;
Tweener.addTween(updaterVariable, {time:2, transition:"linear", '10':1000, onUpdate:tweenerUpdate});
不确定您使用的是哪种补间软件,但它适用于 TweenMax:
private var arr:Array;
public function Main() {
arr = [];
arr.push(0);
arr.push(0);
arr.push(t);
TweenMax.to(arr, 1000, { '2' : 1000 } );
addEventListener(Event.ENTER_FRAME, onframe);
}
private function onframe(e:Event):void {
trace(arr[2]);//outputs expected numbers
}