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スキルグラフ

Get Adobe Flash player
by pon 26 Jul 2010
/**
 * Copyright pon ( http://wonderfl.net/user/pon )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/ck9h
 */

package {
    import flash.display.Sprite;
    public class FlashTest extends Sprite {
        private var diagram:Diagram=new Diagram();
        public function FlashTest() {
            // write as3 code here..
            diagram.list=[
                ["As",70],
                ["Animation",40],
                ["Mobile",80],
                ["Smartphone",10],
                ["Server side",10]
            ];
            addChild(diagram);
            diagram.render();
            diagram.width=stage.stageWidth;
            diagram.height=stage.stageHeight;
            diagram.scaleX>diagram.scaleY?diagram.scaleX=diagram.scaleY:diagram.scaleY=diagram.scaleX;
            diagram.x=diagram.width/2;
            diagram.y=diagram.height/2+50;
        }
    }
    
}
import flash.geom.Point;
import flash.display.DisplayObjectContainer;
import flash.text.TextFormat;
import flash.text.TextField;
import flash.text.TextFieldAutoSize;
import flash.display.Sprite;
class Diagram extends Sprite{
    public var list:Array=[];
    private var ragList:Array=[];
    public var maxValue:Number
    public function Diagram(_maxValue:Number=100){
        maxValue=_maxValue;
    }
    public function render():void{
        var ror:Number=(360/list.length)*Math.PI/180;
        graphics.lineStyle(1,0x666666)
        var arr:Array=[];
        for(var i:uint=0;i<list.length;i++){
            ragList[i]=[Math.sin(ror*i),Math.cos(ror*i)*-1];
            arr.push(new Point(ragList[i][0]*maxValue,ragList[i][1]*maxValue));
        }
        YuruLine.draw(this,arr,8,2);
        
        graphics.lineStyle(1,0xaaaaaa)
        for(i=0;i<list.length;i++){
            arr=[new Point(0,0),new Point(ragList[i][0]*maxValue,ragList[i][1]*maxValue)]
            YuruLine.draw(this,arr,8,2,false);
        };
        
        graphics.lineStyle(1,0xFF0000,0.6)
        graphics.beginFill(0xFF0000,0.2);
        arr=[]
        arr.push(new Point(0,list[0][1]*-1))
        for(i=1;i<list.length;i++){
            var _x:Number=ragList[i][0]*list[i][1];
            var _y:Number=ragList[i][1]*list[i][1];
            arr.push(new Point(_x,_y))
        }
        YuruLine.draw(this,arr,8,2);
        
        for(i=0;i<list.length;i++){
            var tf:TextField=new TextField()
            tf.autoSize=TextFieldAutoSize.LEFT
            tf.defaultTextFormat=new TextFormat(null,12,0x000000);
            tf.text=list[i][0]
            tf.x=ragList[i][0]*(maxValue+20)-tf.width/2
            tf.y=ragList[i][1]*(maxValue+20)-tf.height/2
            addChild(tf);
        }

    }

}
class YuruLine{
    public static function draw(target:Sprite,arr:Array,sp:uint,yure:uint,re:Boolean=true):void{
        var index:uint=1
        var moku:Point=arr[1]
        var now:Point=arr[0]
        if(re)arr.push(new Point(arr[0].x,arr[0].y));
        target.graphics.moveTo(now.x,now.y);
        while(true){
            if(sp==0)break
            var length:Number=Point.distance(moku,now)
            now.x+=(moku.x-now.x)*(sp/length)+(Math.random()*yure-yure/2)
            now.y+=(moku.y-now.y)*(sp/length)+(Math.random()*yure-yure/2)
            target.graphics.lineTo(now.x,now.y);
            if(length<sp*2){
                index++
                if(index==arr.length)break
                moku=arr[index];
            };
        }
        target.graphics.lineTo(arr[arr.length-1].x,arr[arr.length-1].y);
    }
}