forked from: forked from: Tween24.pauseAllTweens

by ProjectNya forked from forked from: Tween24.pauseAllTweens (diff: 25)
♥0 | Line 40 | Modified 2012-12-21 15:58:35 | MIT License
play

ActionScript3 source code

/**
 * Copyright ProjectNya ( http://wonderfl.net/user/ProjectNya )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/njmM
 */

// forked from ProjectNya's forked from: Tween24.pauseAllTweens
// forked from yozamurai's Tween24.pauseAllTweens
package {
    import flash.display.*;
    import flash.events.*;
    import a24.tween.*;
    public class FlashTest extends Sprite {
        
        private var _tw:Tween24;
        private var _box1:Sprite = new Sprite();
        private var _box2:Sprite = new Sprite();
            
        public function FlashTest() {
            // write as3 code here..
            _box1.graphics.beginFill(0xFF0000);
            _box1.graphics.drawRect(0,0,100,100);
            addChild(_box1);
            _box2.graphics.beginFill(0x0000FF);
            _box2.graphics.drawRect(0,0,100,100);
            addChild(_box2);
            _box2.x = 100;
            
            _tw = Tween24.serial(
                Tween24.tween(_box1, 4).y(200), 
                Tween24.tween(_box2, 4).y(200)
            );
            _tw.play();
            
            _box1.addEventListener(MouseEvent.CLICK , pause);
            _box2.addEventListener(MouseEvent.CLICK , pause);
        }
        
        private function pause(e:MouseEvent):void{
            _box1.removeEventListener(MouseEvent.CLICK , pause);
            _box2.removeEventListener(MouseEvent.CLICK , pause);
            _box1.addEventListener(MouseEvent.CLICK , play);
            _box2.addEventListener(MouseEvent.CLICK , play);
            Tween24.pauseAllTweens().play();
        }
        private function play(e:MouseEvent):void {
            _box1.removeEventListener(MouseEvent.CLICK , play);
            _box2.removeEventListener(MouseEvent.CLICK , play);
            _box1.addEventListener(MouseEvent.CLICK , pause);
            _box2.addEventListener(MouseEvent.CLICK , pause);
            _tw.play();
        }


    }
}