0 Replies Latest reply on Aug 19, 2011 5:20 AM by gotoAndHelp ( please )

    why does my movieclip centre on click (using the drag method)

    gotoAndHelp ( please ) Level 1

      I have a movieclip, that is draggable (horizontally), i have this code (helped achieved by Kglad!):

       

      It has a nice effect, but when i click to drag the movieclip jums to its registration point.

       

       

      var completeTween:Boolean;

      var finalMouseY:int;

      var startMouseY:int;

      mc.addEventListener(MouseEvent.MOUSE_DOWN, onDown1);

       

       

      mc.buttonMode = false;

       

      function onDown1(e:MouseEvent):void

      {

      startMouseY = mouseY;

      completeTween = false;

      stage.addEventListener(MouseEvent.MOUSE_UP,onUp1);

      MovieClip(e.currentTarget).addEventListener(Event.ENTER_FRAME,tweenF);

      }

       

      function tweenF(e:Event):void

      {

      var mc:MovieClip = MovieClip(e.currentTarget);

       

      if (completeTween)

      {

      mc.y = .5*(mc.y+Math.min(745.75,finalMouseY));

      if (Math.abs(mc.y - Math.min(745.75,finalMouseY)) < 1)

      {

       

      e.currentTarget.removeEventListener(Event.ENTER_FRAME,tweenF);

       

      }

      }

      else

      {

      mc.y = .5*(mc.y+Math.min(745.75,mouseY-startMouseY));

      }

      }

       

       

       

      function onUp1(e:MouseEvent):void

      {

      completeTween = true;

      finalMouseY = mouseY - startMouseY;

      stage.removeEventListener(MouseEvent.MOUSE_UP,onUp1);

      }