5 Replies Latest reply on Mar 28, 2009 7:27 PM by Justin Putney

    'Throwing' images

      I have created a drag function and this works fine, however, i was wondering whether it was possible to make images look like they are thrown across the page, so when you let go at speed they continue going.

      Also, can you determine an action depending on where theyre thrown?
      Heres my drag function;

      obj.onPress = function(){

      Obj.onRelease = function(){

        • 1. Re: 'Throwing' images
          Ned Murphy Adobe Community Professional & MVP
          Do you have any kind of background in physics? You will likely need one to get something working along these lines, and while you might get lucky, I don't think anyone is going to solve this for you.... It can get fairly complicated and your description isn't clear enough as to the intent of how things travel and what kind of action you intend to determine when they are thrown.

          • 2. Re: 'Throwing' images
            Rothrock Level 5
            Every frame you will need to record the x and y of the drag's current location. You can then figure out the velocity in the x and y direction by subtracting the x,y of the last frame from the current value, finally swap the new x,y into the old x,y, and repeat.

            Don't do anything with the velocities until the user let's go. Then use them to move the item.

            As NedWebs points out the devil IS in the details. There are so many ways to go with this, but the basic idea is what is used in general. If you are serious about this kind of stuff I recommend Keith Peters' book, "Making Things Move!" He has a great simple approach to understanding things like velocity, acceleration, throw and gravity, friction, etc.
            • 3. Re: 'Throwing' images
              iinfinity8 Level 1
              Ok thankyou very much for helping me, I had no idea it would be so hard , on a related issue is there a way of going to a particular frame when an object falls inside a particular area?

              • 4. Re: 'Throwing' images
                Ned Murphy Adobe Community Professional & MVP
                Look into the hitTest() method of movieclips
                • 5. Re: 'Throwing' images
                  Justin Putney Level 2
                  I second the recommendation on Keith Peters' book. I return to that book for stuff like this all the time.