Search code examples
actionscript-3

Equation to convert MouseX, MouseY value to 0,0


I have a various objects on the stage which have handles placed around the bounds of each object. I want to resize the object by pressing and dragging on a handle like you would when resizing in Photoshop. I envision this by pressing on a handle, reset the mouseX, mouseY coordinates to 0,0 and when dragging the handle the Mouse x,y value increases or decreases. I was wanting to use that value and add it to the objects width or height. For example: Mouse moves 2px and the value output is 2px and so on.

Object.height += //mouseY equation starting from 0 when pressed


Solution

  • you can store the MouseX and MouseY in variables when the mouse button is down and the cursor is on the handler then subtract them from the new corresponding MouseX and MouseY when the mouse button is up.

    Now you can add these values to your height and width of your objects.