Graphics.drawPath( 2010-5-21)
♥0 |
Line 32 |
Modified 2010-05-22 16:42:12 |
MIT License
archived:2017-03-20 06:52:48
ActionScript3 source code
/**
* Copyright Kazutaka ( http://wonderfl.net/user/Kazutaka )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/u5YB
*/
package {
import flash.display.GraphicsPathCommand;
import flash.display.GraphicsPathWinding;
import flash.display.Shape;
import flash.display.Sprite;
public class FlashTest extends Sprite {
public function FlashTest() {
// write as3 code here..
var myShape:Shape = setDrawPathSqare( 20, 20, 200, 150,0xcccccc);
this.addChild( myShape );
}
public function setDrawPathSqare(nx:Number,ny:Number,nw:Number,nh:Number,
nCol:uint):Shape{
var commands:Vector.<int>=new Vector.<int>();
commands.push( GraphicsPathCommand.MOVE_TO);
commands.push( GraphicsPathCommand.LINE_TO);
commands.push( GraphicsPathCommand.LINE_TO);
commands.push( GraphicsPathCommand.LINE_TO);
var data:Vector.<Number>=new Vector.<Number>();
data.push(nx,ny);
data.push(nx+nw,ny);
data.push(nx+nw,ny+nh);
data.push(nx,ny+nh);
data.push(nx, ny);
var winding:String=GraphicsPathWinding.EVEN_ODD;
var shape:Shape = new Shape();
shape.graphics.beginFill( nCol );
shape.graphics.drawPath( commands, data, winding );
shape.graphics.endFill();
return shape;
}
}
}