Needed help on picking up an img and putting in down.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • xi4n9
    New Member
    • Sep 2008
    • 3

    Needed help on picking up an img and putting in down.

    im a newbie to action script stuff in flash,currently needed help on my 2nd flash annimation to work out. i would like to know how to pick up an item and put in down as i dont want to drag the item...

    as an example, i want to pick up an apple and the apple follows the cursor moving,then i want to put in down onto a pig's mouth and it will go to a scene where the pig eats the apple.i want the apple automatically dissapear when i click on the pig's mouth.

    sorry for the noob questions,i hope some one could help me to solve this problem as i know only how to click and drag and hitTest... not more than 10 action scripts i've learn...
  • bnashenas1984
    Contributor
    • Sep 2007
    • 257

    #2
    You need 2 commands:
    startDrag & stopDrag

    The first one will lock the item to the mouse cursor and move it arround as the user moves the mouse cursor and the second one will drop the object where the mouse cursor is

    Read more about these functions on AS help

    Good luck

    Comment

    • xi4n9
      New Member
      • Sep 2008
      • 3

      #3
      Originally posted by bnashenas1984
      You need 2 commands:
      startDrag & stopDrag

      The first one will lock the item to the mouse cursor and move it arround as the user moves the mouse cursor and the second one will drop the object where the mouse cursor is

      Read more about these functions on AS help

      Good luck
      yea,thanks for the help,but it doesnt work,i can drag the apple,but i cant pick it up just using a click and put it down using another 2nd click.how can i do that?

      Comment

      • bnashenas1984
        Contributor
        • Sep 2007
        • 257

        #4
        Ok
        Lets say you have an object (apple) on the stage called:
        myApple_mc

        what you need to do is to add an event listener like this:

        Code:
        myApple_mc.addEventListener(MouseEvent.CLICK, pickUp);
        function pickUp(event:Event):void
        {
             myApple_mc.startDrag();
        }
        So, this event listener will trigger the function called pickUp as soon as you click on the apple and the function will start dragging the apple.

        There are other options you can use instead of CLICK on the first line like:
        MOUSE_OVER
        MOUSE_DOWN
        MOUSE_UP
        MOUSE_OUT

        Note: this script will only work on AS3.

        Comment

        • xi4n9
          New Member
          • Sep 2008
          • 3

          #5
          Originally posted by bnashenas1984
          Ok
          Lets say you have an object (apple) on the stage called:
          myApple_mc

          what you need to do is to add an event listener like this:

          Code:
          myApple_mc.addEventListener(MouseEvent.CLICK, pickUp);
          function pickUp(event:Event):void
          {
               myApple_mc.startDrag();
          }
          So, this event listener will trigger the function called pickUp as soon as you click on the apple and the function will start dragging the apple.

          There are other options you can use instead of CLICK on the first line like:
          MOUSE_OVER
          MOUSE_DOWN
          MOUSE_UP
          MOUSE_OUT

          Note: this script will only work on AS3.
          Thanks alot for the reply!!! i've worked out the flash.^^
          i tried to decompile some flash games and take a look on their script.
          there it goes...by the way,cant use ur reply,but i've try on AS3,it works!
          thanks again...the flash i need to work it on AS2 only...
          thanks for the reply.

          Comment

          • joedeene
            Contributor
            • Jul 2008
            • 579

            #6
            Originally posted by xi4n9
            Thanks alot for the reply!!! i've worked out the flash.^^
            i tried to decompile some flash games and take a look on their script.
            there it goes...by the way,cant use ur reply,but i've try on AS3,it works!
            thanks again...the flash i need to work it on AS2 only...
            thanks for the reply.
            Try something similar like this

            Code:
            var dragObj = _root.my_mc;
            dragObj.onPress = function() {
            	dragObj.startDrag();
            };
            dragObj.onRelease = function() {
            	dragObj.stopDrag();
            };
            joedeene

            Comment

            Working...