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

test 2011-2-5

プロファイラ
Get Adobe Flash player
by k2syndrome_g 06 Feb 2011
/**
 * 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/7XoA
 */

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;//生成速度
        public function FlashTest() {
            tf=new TextField;
            tf.text="test"
            this.addChild(tf);
            this.addEventListener(Event.ENTER_FRAME,loop);
            SWFProfiler.init(this);//プロファイラ
        }
        private function loop(e:Event):void{
            if(time==10){
                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 life:Number=0;//寿命
    private var size:Number;//半径
    private var vx:Number;//x速度
    private var vy:Number=0;//y速度
    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 {
        if(life>300){//自壊
            this.removeEventListener(Event.ENTER_FRAME,move);
            Object(parent).removeChild(this);
        }
        vy+=9.8/10;//重力
        this.x+=vx;
        this.y+=vy;
        if(this.y>=465-size){
            this.y=465-size;
            vy=det(vy);
        }
        if(this.x>=465-size){
            this.x=465-size;
            vx=det(vx);
        }
        if(this.x<size){
            this.x=size;
            vx=det(vx);
        }
        life++;
    }
    private function det(velo:Number,bound:Number=1.0,e:Number=0.8):Number{
        if(Math.abs(velo)<bound){
            velo=0;
        }else{
            velo*=-e;
        }
        return velo;
    }
}