flash on 2014-5-14

by maxs.maxs.90
♥0 | Line 48 | Modified 2014-05-15 17:34:15 | MIT License
play

ActionScript3 source code

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

package {
    import flash.display.*;
    import flash.events.*;
    public class FlashTest extends Sprite {
        private var maxPointNum:Number = 100;
        private var num:int = 0;
        private var point:Chs;
        public var st:Number = 5;
        public function FlashTest() {
            // write as3 code here..
            var B:Bitmap = new Bitmap( new BitmapData(stage.stageWidth,stage.stageHeight,false,0x000000) );
            addChild(B);
            addEventListener(Event.ENTER_FRAME,function frr(event:Event){ if(num < maxPointNum) draw(); });
        }
        function draw():void{
            //
            num ++;
            var angle:int = 0;
            point = new Chs( Math.floor(Math.random() * 2 + 1) * st );
            addChild(point);
            point.x = mouseX + Math.floor( Math.random() * 16 - 8 ) * st;
            point.y = mouseY + Math.floor( Math.random() * 16 - 8 ) * st;
            point.addEventListener(Event.ENTER_FRAME,function fr(event:Event){
                var t:Chs = event.target as Chs;
                angle += st;
                t.pointMove(angle,st);
                if(t.alpha > 0) return;
                //
                num --; 
                t.removeEventListener(Event.ENTER_FRAME, fr);
                removeChild(t);
                t = null;
            });
            //
        }

    }
}
//
import flash.filters.GlowFilter;
import flash.display.*;
class Chs extends Shape{
    //
    public function Chs(cf:Number = 1):void{
        graphics.beginFill(Math.random() * 0xffffff);
        graphics.drawRect(0,0,cf,cf);
        graphics.endFill();
        //  
    }
    public function pointMove(angle:Number,st:Number):void{
        alpha -=0.007;
        y += Math.cos(angle * (Math.PI / 180)) * st;
        x += Math.sin(angle * (Math.PI / 180)) * st;
        st -= 0.03;
        //
    }
}