flash on 2012-8-19

by bradsedito
♥0 | Line 33 | Modified 2012-08-19 13:20:40 | MIT License
play

ActionScript3 source code

/**
 * Copyright bradsedito ( http://wonderfl.net/user/bradsedito )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/jRfO
 */






package 
{
    import flash.display.*
    import flash.events.*
    import flash.ui.*   
    
    
    public class FlashTest extends Sprite 
    {
        private var bitmapDraw:Bitmap;
        private var drawBMPData:BitmapData;
        
        
        public function FlashTest() 
        {
            this.graphics.lineStyle(10, 0xff6900);
            stage.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
            stage.addEventListener(MouseEvent.MOUSE_UP, mouseUpHandler);
            
            drawBMPData = new BitmapData(stage.stageWidth, stage.stageHeight, true, 0x000000);
            bitmapDraw = new Bitmap(drawBMPData);
            
            addChild(bitmapDraw);            
        }
        
        
        private function mouseDownHandler(event:MouseEvent):void
        {
            this.graphics.moveTo(event.stageX, event.stageY);
            stage.addEventListener(MouseEvent.MOUSE_MOVE, mouseMoveHandler);
        }
            
            
        private function mouseMoveHandler(event:MouseEvent):void
        {
            this.graphics.lineTo(event.stageX, event.stageY);
        }
            
            
        private function mouseUpHandler(event:MouseEvent):void
        {
            stage.removeEventListener(MouseEvent.MOUSE_MOVE, mouseMoveHandler);
        }    
    
    }
}