flash on 2012-9-20

by russ
♥0 | Line 34 | Modified 2012-09-20 12:20:01 | MIT License
play

ActionScript3 source code

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

package  {

import com.gskinner.motion.GTween;
import com.gskinner.motion.easing.*;

import flash.display.Shape;
import flash.display.Sprite;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flash.events.MouseEvent;

public class GTweenInterrupt extends Sprite {

    // Constants:

    // Public Properties:

    // Protected Properties:
    protected var tweens:Array = [];

    // Initialization:
    public function GTweenInterrupt() {
        stage.align = StageAlign.TOP_LEFT;
        stage.scaleMode = StageScaleMode.NO_SCALE;

        stage.color = 0x000000;

        // draw a bunch of circles, and set up tweens for them:
        for (var i:int=0; i<25; i++) {
            // draw the circle, and put it on stage:
            var circle:Shape = new Shape();
            circle.graphics.lineStyle(15,0x113355, 1-i*0.04);
            circle.graphics.drawCircle(0,0,(i+1)*4);
            circle.x = Math.random()*550;
            circle.y = Math.random()*400;
            circle.blendMode = "add";
            addChild(circle);

            // set up a tween for each circle (initially tweening to the center):
            var circleTween:GTween = new GTween(circle, 0.5+i*0.08, {x:275,y:200}, {ease:Bounce.easeOut});
            tweens.push(circleTween);
            //var alphaTween:GTween = new GTween(circle.graphics.lineStyle(), 10, {})
        }

        stage.addEventListener(MouseEvent.CLICK,handleClick);
    }

    // Public getter / setters:

    // Public Methods:

    // Protected Methods:
    protected function handleClick(evt:MouseEvent):void {
        // update each tween with the new end property values.
        // note that I didn't create a new tween object, but reused the existing one instead.
        for (var i:int=0; i<tweens.length; i++) {
            tweens[i].setValues({x:mouseX,y:mouseY});
        }
    }
}

}