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 fumix 24 Dec 2008
    Embed
// write as3 code here..
package
{
	import flash.display.MovieClip;
        import flash.text.* 
	public class Foo extends MovieClip
	{
	    public function Foo()
		{
                    var sp:polygonLine = new polygonLine(120,7);
                    sp.x = stage.stageWidth / 2;
                    sp.y = stage.stageHeight / 2;
                    addChild(sp);
                    var _tf:TextField = new TextField;
                    _tf.text = 'はろーわんだふる';
                    _tf.x = stage.stageWidth / 2 - _tf.width/2;
                    _tf.y = stage.stageHeight /2;
                    addChild(_tf);

		}		
	}
}

	import flash.display.Sprite;
 
	class polygonLine extends Sprite
	{
		public var radius:Number;
		public var color:uint;
		public var vertex:int;
		
		
		public function polygonLine(radius:Number=40,vertex:int=6,color:uint=0xff0000)
		{
			this.radius = radius;
			this.color = color;
			this.vertex = vertex;
			init();
		}
		public function init():void
		{
			//角度
			var rad:Number = 2*Math.PI/vertex;
			//頂点の座標
			var x:Number = radius*Math.cos(0);
			var y:Number = radius*Math.sin(0);
			//ラインスタイル
			graphics.beginFill(color); 
                        //graphics.lineStyle(1,color,1.0);
			//ポイントを移動
			graphics.moveTo(x,y);
			//頂点数でループ
			for(var i:int = 1;i<vertex;i++){
				//各頂点の座標を求める
				x = radius*Math.cos(rad*i);
				y = radius*Math.sin(rad*i);
				trace('x:'+x+' y:'+y);
				//線を引く
				graphics.lineTo(x,y);
			}
			//線を引く(最後)
			x = radius*Math.cos(0);
			y = radius*Math.sin(0);
			graphics.lineTo(x,y);
                        graphics.endFill(); 
		}
		
	}