skip to Main Content

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

2

Answers


  1. Chosen as BEST ANSWER

    Thanks, that worked with a bit of tweaking.

    var StartPointY = stage.mouseY;
    var StartHeight = SelectedRoom.height;
            stage.addEventListener(MouseEvent.MOUSE_MOVE, TransformShape);
            function TransformShape(e: Event): void {
                if (TransformMode == "Height") {
                    SelectedRoom.height = StartHeight + Math.round(StartPointY - stage.mouseY) * 2;
                }
    }


  2. 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.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search