Painter 1 Saqoosha forked:1 favorite:0 lines:40 license : MIT License modified : 2013-05-10 14:11:30 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; /** * @author Saqoosha */ [SWF(backgroundColor="#000000", frameRate="60", width="475", height="475")] public class Painter1 extends Sprite { private var _canvasData:BitmapData = new BitmapData(475, 475, false, 0xffffff); private var _canvas:Bitmap = new Bitmap(_canvasData); private var _brush:Shape = new Shape(); public function Painter1() { stage.scaleMode = StageScaleMode.NO_SCALE; stage.addEventListener(MouseEvent.MOUSE_DOWN, _mouseDownHandler); addChild(_canvas); _brush.graphics.beginFill(0xff0000); _brush.graphics.drawCircle(0, 0, 2); _brush.graphics.endFill(); } private function _mouseDownHandler(event:MouseEvent):void { stage.addEventListener(MouseEvent.MOUSE_MOVE, _mouseMoveHandler); stage.addEventListener(MouseEvent.MOUSE_UP, _mouseUpHandler); } private function _mouseMoveHandler(event:MouseEvent):void { _brush.x = event.stageX; _brush.y = event.stageY; _canvasData.draw(_brush, _brush.transform.matrix); } private function _mouseUpHandler(event:MouseEvent):void { stage.removeEventListener(MouseEvent.MOUSE_MOVE, _mouseMoveHandler); stage.removeEventListener(MouseEvent.MOUSE_UP, _mouseUpHandler); } } } Code Fullscreen Preview Fullscreen MouseEvent.MOUSE_MOVE MouseEvent.MOUSE_UP MouseEvent stageY stageX StageScaleMode.NO_SCALE MouseEvent.MOUSE_DOWN sort new page view favorite forked pv 1488 Painter 2 Saqoosha forked:1 favorite:1 lines:46 ( diff:19 )