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

Filed under:
|
|

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.

alt text

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

Related posts about flash

Related posts about tweener

  • reset, Tweener, AS3

    as seen on Stack Overflow - Search for 'Stack Overflow'
    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… >>> More

  • Caurina Tweener and Alpha

    as seen on Stack Overflow - Search for 'Stack Overflow'
    Hi guys, Usually I work with TweenLite but I had to modify the code of someone else who worked with Caurina Tweener. I have a basic problem with it! On my scene, I have a simple movie clip filled with black. Into this movieclip a bitmap file (jpg). When I make a tween on the alpha of my mc, it… >>> More

  • Gnome-shell fails to load on 12.10

    as seen on Ask Ubuntu - Search for 'Ask Ubuntu'
    I'm usually the one answering questions, but in this I'm throughly stumped! My Setup: Ubuntu 12.10 (Dist upgrade form 12.04) ATI M96 [Mobility Radeon HD 4650] Upon the first installation of 12.10 I had all kinds of issues getting the Legacy ATI drivers to install (I guess the source for the drivers… >>> More

  • Bring object to the front, in Flash AS3

    as seen on Stack Overflow - Search for 'Stack Overflow'
    Hi All, i have the below code, which is basically animating object across the screen, when roll-over happens it pauses the anim, and displays some information. Everything works fine, but when its paused, i wold like that current object to be 'on top' so other items run behind. I have looked at setChildIndex… >>> More

  • skips nines in counter object, AS3

    as seen on Stack Overflow - Search for 'Stack Overflow'
    It's not that noticeable at first, but my counter skips over to zero and ignores the nines. How can I get my counter to not skip over the nines? my FLA import flash.display.Sprite; import flash.events.Event; import flash.utils.Timer; import flash.events.TimerEvent; var timer:Timer; var count:int… >>> More