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

flash on 2009-4-20

////////////////////////////////////////////////////
小さい円または四角形で円を描く
///////////////////////////////////////////////////
Get Adobe Flash player
by gen_suke 19 Apr 2009
    Embed
//////////////////////////////////////////////////////
//
//    小さい円または四角形で円を描く
//
/////////////////////////////////////////////////////
package{
    import flash.display.Sprite;
    import flash.events.MouseEvent;
    import flash.events.TimerEvent;
    import flash.utils.Timer;

    [SWF(width = 465, height = 465, backgroundColor = 0xffffff, frameRate = 30)]
    public class Test extends Sprite{
        public function Test(){
            stage.addEventListener(MouseEvent.CLICK,clickHandler);
        }
        public function clickHandler(event:MouseEvent):void{
            //図形オブジェクト格納
            var figureArray:Array = new Array();
            //終点格納
            var pointArray:Array= new Array();

            var createFigure:Create;
            var num:Number = Math.random();
            if (num > 0.6){
       	        createFigure= new CreateRect(figureArray,pointArray);
            }else{
                createFigure= new CreateCircle(figureArray,pointArray);
            }
            //図形の作成と終点座標の算出
            createFigure.figureCreate();
            figureArray = createFigure.FigureArray;
            pointArray  = createFigure.PointArray;
            circleAdd(figureArray);
 
            var mytimer:Timer = new Timer(15,50);
            var myrender:MyRender = new MyRender(figureArray,pointArray,mytimer);

            mytimer.addEventListener(TimerEvent.TIMER, function(event:TimerEvent):void {
                myrender.render(); } );
            mytimer.addEventListener(TimerEvent.TIMER_COMPLETE,function(event:TimerEvent):void {
                circleErase(figureArray,pointArray); } );
            mytimer.start();
        }
        public function circleAdd(figureArray:Array):void{
            for(var i:uint =0 ; i < figureArray.length ; i++ ){
                this.stage.addChild(figureArray[i]);
	    }
        }  
       public function circleErase(figureArray:Array,pointArray:Array):void{
           for(var i:uint =0 ; i < figureArray.length ; i++ ){
               this.stage.removeChild(figureArray[i]);
           }
           pointArray = null;
           figureArray = null;
       } 
    }
}

//図形の情報を管理
import flash.display.Sprite;
import flash.geom.Point;

class Create extends Sprite{
    //5度ずつで72個のボールを配置
    protected const BALL_NUM:uint = 72;
    protected const BALL_ANGLE:uint = 5;
    protected var figureArray:Array; //図形
    protected var pointArray:Array;  //頂点
    protected var radius:uint; 
    protected var figureSize:uint;
    public function Create(figureArray:Array,pointArray:Array){
        this.figureArray = figureArray;
        this.pointArray = pointArray;
        radius = 150 * Math.random() + 70;  // 描かれる円の半径をランダム
        figureSize = radius / 40 + 1;       // 円の半径を基準に図形の半径を決定
    }
    public function get FigureArray():Array{
        return figureArray;
    }
    public function get PointArray():Array{
        return pointArray;
    }
    //図形を作成
    public function create():void{
       //over_ride
    }
    //図形の終点を計算	
    public function mathPoint():void{
        var angle:uint = 0;
        var radian:Number = 0;
        for( var j:uint = 0 ; j < figureArray.length ; j++ ){
            radian= Math.PI * angle / 180;
            angle += BALL_ANGLE;
            var point:Point = new Point();
            point.x = mouseX + ( radius * Math.cos(radian) );
            point.y = mouseY + ( radius * Math.sin(radian) );
            pointArray.push(point);   	 	
        }			
    }
    public function figureCreate():void{
        for( var i:uint = 0 ;i < BALL_NUM ; i++ ){
            create();
        }
	mathPoint();
    }
}
class CreateRect extends Create
{
    public function CreateRect(circleArray:Array,pointArray:Array)
    {
 	super(circleArray,pointArray);
    }
    //四角形を作成
    override public function create():void
    {
        var rect:Sprite = new Sprite();
       	rect.graphics.beginFill(0xFFFFFF * Math.random());
	rect.graphics.drawRect(0, 0, figureSize, figureSize);
	rect.x = mouseX;
	rect.y = mouseY;
	rect.graphics.endFill();
	figureArray.push(rect);
    }
}

import flash.display.Sprite;
class CreateCircle extends Create{
    public function CreateCircle(circleArray:Array,pointArray:Array){
        super(circleArray,pointArray);
    }
    //円を作成
    override public function create():void{
        var circle:Sprite = new Sprite();
        circle.graphics.beginFill(0xFFFFFF * Math.random());
        circle.graphics.drawCircle(0, 0, figureSize);
        circle.x = mouseX;
        circle.y = mouseY;
        circle.graphics.endFill();
        figureArray.push(circle);
    }
}

//図形を動かす
import flash.geom.Point;
import flash.display.Sprite;
import flash.utils.Timer;
class MyRender extends Sprite{
    private var figureArray:Array;
    private var pointArray:Array;
    private var mytimer:Timer;
    public function MyRender(figureArray:Array,pointArray:Array,mytimer:Timer){
        this.figureArray = figureArray;
        this.pointArray = pointArray;
        this.mytimer = mytimer;
    }
    public function render():void{
        var ratio:Number = mytimer.currentCount / mytimer.repeatCount;
        for(var i:uint =0 ; i < figureArray.length ; i++ ){
            figureArray[i].x += (pointArray[i].x - figureArray[i].x)/20;
            figureArray[i].y += (pointArray[i].y - figureArray[i].y)/20;
            figureArray[i].alpha = 1- ratio ;
        }
    }
}