1 Reply Latest reply on Mar 4, 2009 4:31 PM by Newsgroup_User

    How to Drag and Resize an Image Without Using HSlider

    alice_data Level 1
      Hi,

      I have been stuck around this for days and I wonder if anyone on this forum can help me out.
      The code works, but what I really want to do is to allow users to at least click on the image and resize it dynamically without me having to limit users to only shrink down the size 25 pixels at a time.

      There are some manuals I found telling me to use Hsliders, but I don't want users to be restricted to that either. Could anyone please give me some guidance on how to make this work?

      Thanks in advance.
        • 1. Re: How to Drag and Resize an Image Without Using HSlider
          Level 7
          I was dealing with a similar problem recently. The way that I solved it
          was to attach a listener for the mouse down event. Then, I saved the
          global coordinates of the click (to variables called lastX and lastY),
          and added a mouse move listener to the stage and a mouse up listener to
          the stage.

          The mouse move listener calculates the change in the mouse coordinates
          from the last saved coordinates, and changes the object size using that
          delta value. Then it saves the new coordinates to lastX and lastY.

          Finally, the mouse up listener removes itself and the mouse move
          listener from the stage.

          The reason I added the listeners to the stage rather than the object is
          that the user can move the mouse outside the object before the resize
          has time to occur.