In case Flash no longer exists; a copy of this site is included in the Flashpoint archive's "ultimate" collection.

Dead Code Preservation :: Archived AS3 works from wonderfl.net

forked from: EmitPanda (2)

EmitPanda (2)
Get Adobe Flash player
by undo 06 Jul 2011
/**
 * Copyright undo ( http://wonderfl.net/user/undo )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/6U6q
 */

// forked from ProjectNya's EmitPanda (2)
////////////////////////////////////////////////////////////////////////////////
// EmitPanda (2)
////////////////////////////////////////////////////////////////////////////////

package {

    import flash.display.Sprite;
    import flash.display.MovieClip;
    import flash.events.Event;
    import flash.events.MouseEvent;
    import flash.display.Loader;
    import flash.net.URLRequest;
    import flash.system.Security;
    import flash.system.LoaderContext;
    import net.wonderfl.widget.Wanco;

    [SWF(backgroundColor="#FFFFFF", width="465", height="465", frameRate="30")]

    public class Main extends Sprite {
        private var wanco:Wanco;
        private var emit:EmitParticle;

        public function Main() {
            //Wonderfl.capture_delay(1);
            init();
        }

        private function init():void {
            //wanco = new Wanco();
            emit = new EmitParticle();
            addChild(emit);
        }

    }

}


//////////////////////////////////////////////////
// EmitParticleクラス
//////////////////////////////////////////////////

import flash.display.Sprite;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.display.MovieClip;
import net.wonderfl.widget.Wanco;

class EmitParticle extends Sprite {
    private static var max:uint = 4;
    private var id:uint = 0;
    private var particles:Array;
    private var Panda:Class;
    private static var friction:Number = 0.96;
    private static var gravity:Number = 0.5;

    public function EmitParticle() {
        if (stage) init();
        else addEventListener(Event.ADDED_TO_STAGE, init, false, 0, true);
    }

    private function init(evt:Event = null):void {
        removeEventListener(Event.ADDED_TO_STAGE, init);
        particles = new Array();
        stage.addEventListener(MouseEvent.MOUSE_MOVE, create, false, 0, true);
        addEventListener(Event.ENTER_FRAME, update, false, 0, true);
    }
    private function create(evt:MouseEvent):void {
        var particle:Particle = new Particle();
        particle.id = id;
        addChild(particle);
        var panda:Wanco = new Wanco();
        panda.scaleX = panda.scaleY = 0.6;
        particle.addChild(panda);
        particle.vx = Math.random()*10 - 5;
        particle.vy = -8;
        particle.x = mouseX + Math.random()*20 - 10;
        particle.y = mouseY + Math.random()*20 - 10;
        particles.push(particle);
        id ++;
    }
    private function update(evt:Event):void {
        for (var n:uint = 0; n < particles.length; n++) {
            var particle:Particle = particles[n];
            particle.x += particle.vx;
            particle.y += particle.vy;
            particle.vx *= friction;
            particle.vy *= friction;
            particle.vy += gravity;
            if (particle.y > stage.stageHeight + 20) {
                removeChild(particle);
                particles.splice(n, 1);
                particle = null;
            }
        }
    }

}


//////////////////////////////////////////////////
// Particleクラス
//////////////////////////////////////////////////

import flash.display.Sprite;

class Particle extends Sprite {
    public var id:uint;
    public var vx:Number = 0;
    public var vy:Number = 0;

    public function Particle() {
    }


}