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

basic mouse drag

Get Adobe Flash player
by it_Hing 18 Jun 2012
    Embed
/**
 * Copyright it_Hing ( http://wonderfl.net/user/it_Hing )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/g1di
 */

package {
    import flash.events.MouseEvent;
    import flash.display.Graphics;
    import flash.display.Sprite;
    public class FlashTest extends Sprite {
        public function FlashTest() {
            // write as3 code here..
            
            
            var sprite:Sprite = new Sprite;
            
            sprite.graphics.beginFill(0xff0000);
            sprite.graphics.drawCircle(30, 30, 30);
            sprite.graphics.endFill();
            
            sprite.addEventListener( MouseEvent.MOUSE_DOWN, ooo);
            sprite.addEventListener( MouseEvent.MOUSE_UP, ooo);
            this.addChild( sprite );
            
        }
        
        private function ooo(event:MouseEvent):void
        {
            var sprite:Sprite = event.target as Sprite;
            
            
            if ( event.type == MouseEvent.MOUSE_DOWN )
            {
                sprite.startDrag(); 
            } else {
                sprite.stopDrag();
            }

        }
        
        

    }
}