reset, Tweener, AS3
- by VideoDnd
How do I reset my numbers after they count? I want something like an onComplete function.
DESCRIPTION
My animation advances 120 pixels from it's current position, then flys off the stage.
It was looping, and would yoyo to the bottom before advancing. I don't want my numbers
yoyoing or flying off the stage. My numbers must move 120 pixels forward each count, then
return.
NumbersView.as 'the code works, but in a messed up way as described'
package
{
import flash.display.DisplayObject;
import flash.display.MovieClip;
import flash.utils.Dictionary;
import flash.events.Event;
import caurina.transitions.Tweener;
public class NumbersView extends MovieClip
{
private var _listItems:Array;
private var previousNums:Array;
private const numHeight:int = 120;
public function NumbersView()
{
_listItems = new Array();
previousNums = new Array();
//Tweener.init();
var item:NumberImage;
for (var i:Number = 0; i < 9; i++) {
item = new NumberImage();
addChild(item);
item.x = i * item.width;
_listItems.push(item);
}
}
public function setTime($number:String):void {
var nums:Array = $number.split("");
//trace("$number = " + $number);
for (var i:Number = 0; i < nums.length; i++) {
if (nums[i] == previousNums[i]) continue;
Tweener.removeTweens(_listItems[i]);
//newY:int = -numHeight;
var newY:int = int(nums[i]) * -numHeight;
trace("newY = " + newY);
trace("currY = " + _listItems[i].y);
/*----------------------PROBLEM AREA, RIGHT HERE------------------------*/
//if (_listItems[i].y < 0) _listItems[i].y = numHeight;//
//Tweener.addTween(_listItems[i], { y:newY, time:3 } );//
Tweener.addTween(_listItems[i], { y:_listItems[i].y+newY, time:3 } );//
}
previousNums = nums;
}
}
}
Tweener Example
http://hosted.zeh.com.br/tweener/docs/en-us/parameters/onComplete.html