forked from: forked from: Tween24.pauseAllTweens

by a_24 forked from forked from: Tween24.pauseAllTweens (diff: 5)
♥0 | Line 30 | Modified 2012-12-21 15:55:02 | MIT License
play

ActionScript3 source code

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

// 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 _box:MovieClip = new MovieClip();
            
        public function FlashTest() {
            // write as3 code here..
            _box.graphics.beginFill(0xFF0000);
            _box.graphics.drawRect(0,0,100,100);
            addChild(_box);
            
            _tw = Tween24.serial(
                Tween24.tween(_box, 3).y(200),
                Tween24.tween(_box, 3).x(200)
            );
            _tw.play();
            
            _box.addEventListener(MouseEvent.CLICK , pauseAll);
        }
        
        private function pauseAll(e:MouseEvent):void{
            _box.removeEventListener(MouseEvent.CLICK , pauseAll);
            _box.addEventListener(MouseEvent.CLICK , play);
            Tween24.pauseAllTweens().play();
        }
        private function play(e:MouseEvent):void {
            _box.removeEventListener(MouseEvent.CLICK , play);
            _box.addEventListener(MouseEvent.CLICK , pauseAll);
            _tw.play();
        }


    }
}