Forked from: Saqoosha 's Painter 1 diff:19 Painter 2 @author Saqoosha Saqoosha forked:1 favorite:1 lines:46 license : MIT License modified : 2013-05-10 14:42:18 package { import flash.display.Bitmap; import flash.display.BitmapData; import flash.display.Shape; import flash.display.Sprite; import flash.display.StageScaleMode; import flash.events.MouseEvent; import flash.geom.Point; /** * @author Saqoosha */ [SWF(backgroundColor="#000000", frameRate="60", width="475", height="475")] public class Painter2 extends Sprite { private var _canvasData:BitmapData = new BitmapData(475, 475, false, 0xffffff); private var _canvas:Bitmap = new Bitmap(_canvasData); private var _stroke:Shape = new Shape(); private var _prev:Point = new Point(); public function Painter2() { stage.scaleMode = StageScaleMode.NO_SCALE; stage.addEventListener(MouseEvent.MOUSE_DOWN, _mouseDownHandler); addChild(_canvas); } private function _mouseDownHandler(event:MouseEvent):void { stage.addEventListener(MouseEvent.MOUSE_MOVE, _mouseMoveHandler); stage.addEventListener(MouseEvent.MOUSE_UP, _mouseUpHandler); _prev.x = event.stageX; _prev.y = event.stageY; } private function _mouseMoveHandler(event:MouseEvent):void { _stroke.graphics.clear(); _stroke.graphics.lineStyle(5, 0xff0000, 0.5); _stroke.graphics.moveTo(_prev.x, _prev.y); _stroke.graphics.lineTo(event.stageX, event.stageY); _canvasData.draw(_stroke); _prev.x = event.stageX; _prev.y = event.stageY; } private function _mouseUpHandler(event:MouseEvent):void { stage.removeEventListener(MouseEvent.MOUSE_MOVE, _mouseMoveHandler); stage.removeEventListener(MouseEvent.MOUSE_UP, _mouseUpHandler); } } } Code Fullscreen Preview Fullscreen shirataku stageY stageX MouseEvent.MOUSE_MOVE MouseEvent.MOUSE_UP MouseEvent StageScaleMode.NO_SCALE MouseEvent.MOUSE_DOWN Point sort new page view favorite forked pv 1445 Painter 3 Saqoosha forked:1 favorite:1 lines:96 ( diff:69 )