reset, Tweener, AS3
Posted
by VideoDnd
on Stack Overflow
See other posts from Stack Overflow
or by VideoDnd
Published on 2010-03-17T18:40:32Z
Indexed on
2010/03/17
20:11 UTC
Read the original article
Hit count: 535
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
© Stack Overflow or respective owner