废话不多说
var my:Sprite = new Sprite(); addChild(my); my.graphics.beginFill(0xff0000,.8); my.graphics.drawRect(100,100,100,100); my.graphics.endFill(); my.graphics.beginFill(0xff0000,.8); my.graphics.drawRect(150,150,100,100); my.graphics.endFill();
效果:
var my:Sprite = new Sprite(); addChild(my); my.graphics.beginFill(0xff0000,.8); my.graphics.drawRect(100,100,100,100); my.graphics.drawRect(150,150,100,100); my.graphics.endFill();
var my:Sprite = new Sprite(); addChild(my); my.graphics.beginFill(0xff0000,.8); var commandsPath:Vector.<int> = new Vector.<int>(10); commandsPath[0] = GraphicsPathCommand.MOVE_TO; commandsPath[1] = GraphicsPathCommand.LINE_TO; commandsPath[2] = GraphicsPathCommand.LINE_TO; commandsPath[3] = GraphicsPathCommand.LINE_TO; commandsPath[4] = GraphicsPathCommand.LINE_TO; commandsPath[5] = GraphicsPathCommand.MOVE_TO; commandsPath[6] = GraphicsPathCommand.LINE_TO; commandsPath[7] = GraphicsPathCommand.LINE_TO; commandsPath[8] = GraphicsPathCommand.LINE_TO; commandsPath[9] = GraphicsPathCommand.LINE_TO; var dataPath:Vector.<Number> = new Vector.<Number>(20); dataPath[0]=100; dataPath[1]=100; dataPath[2]=200; dataPath[3]=100; dataPath[4]=200; dataPath[5]=200; dataPath[6]=100; dataPath[7]=200; dataPath[8]=100; dataPath[9]=100; dataPath[10]=150; dataPath[11]=150; dataPath[12]=250; dataPath[13]=150; dataPath[14]=250; dataPath[15]=250; dataPath[16]=150; dataPath[17]=250; dataPath[18]=150; dataPath[19]=150; my.graphics.drawPath(commandsPath,dataPath,GraphicsPathWinding.NON_ZERO); my.graphics.endFill();