Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Drag and Drop movieclip using as3.

    • 0
    • 2
    • 2
    • 0
    • 0
    • 0
    • 0
    • 0
    • 682
    Comment on it

    To drag and drop a movie clip we use two function: 1.startDrag() 2.stopDrag().

    startDrag(): is used to drag a specified movieClip. MovieClip remain draggage until explicitly

    stopped by making call to stopDrag().one movieclip is dragged at a time.

    startDrag() uses two parameter: 1.lockCenter:Boolean : Its default value is false.It specifies whether whether the draggable movieclip locked to the point where the user first clicked the sprite .

    2.bounds:Rectangle:value relative to the coordinates of the Sprite's parent that specify a constraint rectangle for the Sprite

    stopDrag(): It is used to stop the draging movieclip.

    Sample application to show the use of this two method:

    package 
    {
    
        import flash.display.MovieClip;
        import flash.events.MouseEvent;
    
        public class Main extends MovieClip
        {
            var rect:MovieClip;
    
            public function Main()
            {
                // constructor code
                rect = new MovieClip();
                rect.graphics.beginFill(0x660033);
                rect.graphics.drawRect(0, 0, 50, 100);
                this.addChild(rect);
    
                rect.addEventListener(MouseEvent.MOUSE_DOWN, startDragging);
                rect.addEventListener(MouseEvent.MOUSE_UP, stopDragging);
            }
    
            private function startDragging(e:MouseEvent):void
            {
                rect.startDrag();
            }
    
            private function stopDragging(e:MouseEvent):void
            {
                rect.stopDrag();
            }
    
        }
    }
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: