In case Flash no longer exists; a copy of this site is included in the Flashpoint archive's "ultimate" collection.

Dead Code Preservation :: Archived AS3 works from wonderfl.net

MouseDrag?

Get Adobe Flash player
by pasodania 17 Sep 2009
    Embed
/**
 * Copyright pasodania ( http://wonderfl.net/user/pasodania )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/k9k4
 */

package {
    import flash.display.Sprite;
    import flash.events.*;
    public class FlashTest extends Sprite {
        
        public var flag:Boolean = false;
        public function FlashTest() {
            // write as3 code here..
            graphics.lineStyle(1, 0x000000);
            stage.addEventListener( MouseEvent.MOUSE_MOVE, mousemove );
            stage.addEventListener( MouseEvent.MOUSE_DOWN, triggerOn);
            stage.addEventListener( MouseEvent.MOUSE_UP, triggerOFF);
        }
        
        public function mousemove(e:MouseEvent):void{
                
            if(flag){
                graphics.lineTo(e.stageX, e.stageY);
            }
        }
        
        public function triggerOn(e:MouseEvent):void{
            flag = true;
            graphics.moveTo(e.stageX, e.stageY);
        }
        
        public function triggerOFF(e:MouseEvent):void{
            flag = false;
        }
    }
}