单色填充

在执行lineTo()或curveTo()之前调用这个方法,那么绘图API绘制出来的图像将会填充成beginFill()中指定的颜色

另外在执行beginFill()之后需要执行endFill()

package
{
	import flash.display.Sprite;
	import flash.events.MouseEvent;

	[SWF(width=550,height=400,backgroundColor=0xFFFFFF)]
	public class as3 extends Sprite
	{
		public function as3()
		{
			stage.addEventListener(MouseEvent.CLICK, onStageClick);
			drawBackground();
		}
		
		private function drawBackground():void
		{
			graphics.clear();
			graphics.beginFill(Math.random()*0xFFFFFF);
			graphics.lineTo(stage.stageWidth, 0);
			graphics.lineTo(stage.stageWidth, stage.stageHeight);
			graphics.lineTo(0, stage.stageHeight);
			graphics.lineTo(0,0);
			graphics.endFill();
		}
		
		private function onStageClick(event:MouseEvent):void
		{
			drawBackground();
		}
	}
}