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

沸騰するカラフル(謎)

ステージをクリックでパーティクル発生
(modified 10.07.15 AM)
/**
 * Copyright mousepancyo ( http://wonderfl.net/user/mousepancyo )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/48zO
 */

/*
ステージをクリックでパーティクル発生
(modified 10.07.15 AM)
*/
package  {
    import flash.display.Sprite;
    import flash.events.Event;
    import flash.events.MouseEvent;
    import flash.display.DisplayObject;
    
    [SWF(width="465", height="465", backgroundColor="#FFFFFF", frameRate="30")]
    
    public class Main extends Sprite{
        
        private var _incidence:uint;
        private var _list:Vector.<Circle> = new Vector.<Circle>;

        public function Main() {
            stage.addEventListener(MouseEvent.MOUSE_DOWN, go);
        }
        
        private function go(e:MouseEvent):void{
            _incidence = Math.floor(Math.random()*40+10);
            for(var i:int=0;i<_incidence;i++){
                var n:int = Math.floor(Math.random()*49+1);
                var n2:Number = Math.random()*4-2;
                var n3:Number = Math.random()*100-50;
                var _circle:Circle = new Circle(n, n2, Math.floor(Math.random()*2));
                addChild(_circle);
                _circle.x = mouseX+n3;
                _circle.y = mouseY+n3;
                _circle.cacheAsBitmap = true;
                _circle.addEventListener(Event.ENTER_FRAME, _circle.drop);
                _circle.addEventListener(Circle.LIFE_END, removed);
                setChildIndex(_circle, (Math.floor(Math.random()*numChildren)))             
            }
        }
        
        private function removed(e:Event):void{
            e.target.removeEventListener(Event.ENTER_FRAME, e.target.drop);
            e.target.removeEventListener(Circle.LIFE_END, removed);
            removeChild(e.target as DisplayObject);
        }
    }
}

import flash.display.Sprite;
import flash.events.Event;
import flash.geom.Point;
import flash.geom.ColorTransform;

class Circle extends Sprite{
    
    private var _size:int;
    private var _speed:Number;
    private var _v:Point = new Point(0,0)
    private var _k:Number = 0.9;
    private var _ground:int = 465;
    private var _vec:uint;
    private var _life:uint = 100;
    public static const BASE_COLOR:int = 0xFFFFFF;
    public static const LIFE_END:String = "life_end"
    
    public function Circle(size:int, speed:Number, vec:uint=0){
        var newColor:int = BASE_COLOR-(Math.floor(Math.random()*BASE_COLOR));
        graphics.lineStyle(3,0x333333);
        graphics.beginFill(newColor);
        graphics.drawCircle(0,0,size);
        graphics.endFill();
        _speed = speed;
        _size = size;
        _vec = vec;
        this.mouseChildren = false;
    }
    
    public function drop(e:Event):void{
        var n:Number;
        if(_vec==0){
            n = _v.x+e.target.width/200;
            _v.x = n;
        }else{
            n = _v.x-e.target.width/200;
            _v.x = n;
        }
        e.target.x += _v.x;  
        _v.y += _speed;  
        if(e.target.y > (_ground-_size) && _v.y > 0 ){ 
            _v.y = -_v.y*_k;  
        }else if(e.target.y < _size && _v.y < (_ground-_size) ){ 
            _v.y = -_v.y*_k;  
        }else if(e.target.x > (_ground-_size) && _v.x > 0 ){ 
            _v.x = -_v.x*_k;  
        }else if(e.target.x < _size && _v.x < (_ground-_size) ){ 
            _v.x = -_v.x*_k;  
        }
        e.target.y += _v.y; 
        //
        if(_life==0 ){
            death(e.target as Sprite)
        }else{
           _life-- 
        }
    }
    
    private function death(t:Sprite):void{
        if(t.scaleX >= 0){
            t.scaleX-=0.01
            t.scaleY-=0.01
        }else{
             t.removeEventListener(Event.ENTER_FRAME, drop)
             t.removeEventListener(Event.ENTER_FRAME, death)
             dispatchEvent(new Event(Circle.LIFE_END))
        }
    }
}