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: test 2011-2-5

プロファイラ
/**
 * Copyright k2syndrome_g ( http://wonderfl.net/user/k2syndrome_g )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/mdxY
 */

// forked from k2syndrome_g's test 2011-2-5
package {
    import flash.events.Event;
    import flash.display.AVM1Movie;
    import flash.display.Sprite;
    import flash.text.TextField;
    import com.flashdynamix.utils.SWFProfiler;//プロファイラ
    public class FlashTest extends Sprite {
        public var tf:TextField;
        private var time:Number=0;//生成速度
        private var angle:Number=20*Math.PI/180;
        
        public function FlashTest() {
            tf=new TextField;
            tf.text="test"
            this.addChild(tf);
            this.addEventListener(Event.ENTER_FRAME,loop);
            SWFProfiler.init(this);//プロファイラ
            //
            var a:Number=Math.tan(angle);
            var b:Number=465*(1-a);
            this.graphics.lineStyle(1,0x0);
            this.graphics.moveTo(0,b);
            this.graphics.lineTo(465,465);
            Ball.sin2=Math.sin(2*angle);
            Ball.cos2=Math.cos(2*angle);
            Ball.a=a;
            Ball.b=b;
        }
        private function loop(e:Event):void{
            if(time==5){
                var b1:Ball=new Ball();
                addChild(b1);
                time=0;
            }else{
                time++
            }
        }
    }
}
import flash.filters.GradientGlowFilter;
import flash.filters.BevelFilter;
import flash.events.Event;
import flash.display.Graphics;
import flash.display.Shape;
import flash.display.Sprite;
class Ball extends Shape {
    private var size:Number;//半径
    private var vx:Number;//x速度
    private var vy:Number=0;//y速度
    //
    public static var sin2:Number;
    public static var cos2:Number;
    public static var e1:Number=0.8;
    public static var a:Number;
    public static var b:Number;
    
    public function Ball() {//コンストラクタ
        size=10+Math.random()*20;
        vx=(Math.random()-0.5)*10;
        var col:Number=Math.random()*0xFFFFFF;
        this.graphics.beginFill(col,1.0);
        this.graphics.drawCircle(0,0,size);
        var colors:Array=[col,0xFFFFFF];
        var alphas:Array=[0,1];
        var ratios:Array=[0,255];
        this.filters = [new GradientGlowFilter(0,0,colors,alphas,ratios,size+12,size+12,1,2,"outer",true)];
        this.x=size+(465-2*size)*Math.random();
        this.y=0;
        this.addEventListener(Event.ENTER_FRAME,move);
        //
    }
    private function move(e:Event):void {
        vy+=9.8/10;//重力
        this.x+=vx;
        this.y+=vy;
        if(this.y>=this.x*a+b-size){
            this.y=this.x*a+b-size;
            vx+=e1*vy*sin2;
            vy=-e1*vy*cos2;
        }
        if(this.y>500){
            this.removeEventListener(Event.ENTER_FRAME,move);
            Object(parent).removeChild(this);
        }
        
    }

}