绘图板

 

package {
	import flash.display.Sprite;
	import flash.events.MouseEvent;
	public class onDrawingBoard extends Sprite {
		private var ceng:Sprite;
		private var isdown:Boolean=false;
		private var linesize:uint=2;
		private var oldx:Number;
		private var oldy:Number;
		public function onDrawingBoard():void {
			init();
		}
		private function init():void {
			ceng=new Sprite();
			addChild(ceng);
			stage.addEventListener(MouseEvent.MOUSE_DOWN,ondown);
			stage.addEventListener(MouseEvent.MOUSE_MOVE,onmove);
			stage.addEventListener(MouseEvent.MOUSE_UP,onup);
		}
		private function ondown(evt:MouseEvent):void {
			isdown=true;
			oldx=stage.mouseX;
			oldy=stage.mouseY;
		}
		private function onmove(evt:MouseEvent):void {
			if (isdown) {
				ceng.graphics.lineStyle(linesize,0x000000);
				ceng.graphics.moveTo(oldx,oldy);
				ceng.graphics.lineTo(stage.mouseX,stage.mouseY);
				oldx=stage.mouseX;
				oldy=stage.mouseY;
			}
		}
		private function onup(evt:MouseEvent):void {
			isdown=false;
		}
	}
}

 

 

posted @ 2010-05-01 15:01  LT世纪  阅读(185)  评论(0编辑  收藏  举报