I have the following code which works perfectly:
updaterVariable = 0;
Tweener.addTween(this, {time:2, transition:"linear", updaterVariable:1000, onUpdate:tweenerUpdate});
I will get the value of updaterVariable tweened from 0 to 1000 in 2 seconds. My question is whether there is a similar way to tween a variable in an array, for example:
updaterVariable[10] = 0;
Tweener.addTween(this, {time:2, transition:"linear", updaterVariable[10]:1000, onUpdate:tweenerUpdate});
I tried the above code, and its not working. Can anyone help?
You can pass your array to the tweener and use index as a field to be changed:
updaterVariable[10] = 0;
Tweener.addTween(updaterVariable, {time:2, transition:"linear", '10':1000, onUpdate:tweenerUpdate});
Not sure which tweener you are using, however it works with 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
}