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

グラフ 描画(簡易版)

Get Adobe Flash player
by WinField95 05 Feb 2012
    Embed
/**
 * Copyright WinField95 ( http://wonderfl.net/user/WinField95 )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/6zTn
 */

package
{
    import adobe.utils.CustomActions;
    import flash.display.Sprite
    import flash.text.*;
    
    public class Main extends Sprite
    {
        public function Main():void
        {                
    
            x = y = 100; // x=0,y=0の位置を、x=100,y=100の位置にする。
        
            var arr:Array = new Array();
            arr.push(new Cir(0, 0, 0));
            arr.push(new Cir(0, 100, 1));
            arr.push(new Cir(200, 0 , 2));
            arr.push(new Cir(100, 200,3))
                    
            graphics.lineStyle(4.0);
                
            for (var i:int = 0 ; i < arr.length ; i++) {
                graphics.drawCircle(arr[i].getX(), arr[i].getY(), arr[i].getR());
                addChild(arr[i].getT());
            }
            
            
            var matrix:Array = new Array();
            var m0:Array = [0, 0, 1, 0];
            var m1:Array = [0, 0, 1, 0];
            var m2:Array = [1, 1, 0, 1];
            var m3:Array = [0, 0, 1, 0];
            
            
            matrix.push(m0);
            matrix.push(m1);
            matrix.push(m2);
            matrix.push(m3);
            
            for (var i:int = 0 ; i < arr.length ; i++) {
                for (var j:int = i+1 ; j < arr.length ; j++) {
                    if (matrix[i][j] == 1) {
                        
                        var ang:Number = Math.atan2(arr[i].getY() - arr[j].getY() , arr[i].getX() - arr[j].getX());
                        
                        graphics.moveTo(arr[i].getX() - Math.cos(ang) * arr[i].getR(), arr[i].getY() - Math.sin(ang) * arr[i].getR());
                        graphics.lineTo(arr[j].getX() + Math.cos(ang) * arr[j].getR(), arr[j].getY() + Math.sin(ang) * arr[j].getR());
                        
                    }
                }
            }
            
        }
    }
}
import flash.text.TextField;


class Cir {
    
    private var x:Number, y:Number, r:Number, id:Number;
    private var tf:TextField;
    
    function Cir(xx:Number, yy:Number, idd:Number){
        r = 20;
        x = xx;
        y = yy;
        id = idd;
        
        tf = new TextField();
        tf.x = x - 6;
        tf.y = y - 8;
        
        tf.selectable = false;
        tf.text += id;
    }

    public function getX():Number{
        return x;
    }
    public function getY():Number{
        return y;
    }
    public function getR():Number{
        return r;
    }
    public function getT():TextField {
        return tf;
    }
}