Copy link to clipboard
Copied
when i move my object x .. it go away from the stage .. can u help me with function make my object moving inside the stage?! thanx a lot
stop();
stage.addEventListener(MouseEvent.MOUSE_MOVE,mousedown);
function mousedown(e:MouseEvent):void{
girlMc.x = mouseX;
}
Hi.
You can use:
import flash.events.Event;
function mouseMoveHandler(e:Event):void
{
girlMc.x = mouseX;
if (girlMc.x < 0)
girlMc.x = 0;
else if (girlMc.x > stage.stageWidth - girlMc.width)
girlMc.x = stage.stageWidth - girlMc.width;
}
stage.addEventListener(MouseEvent.MOUSE_MOVE, mouseMoveHandler);
I hope this helps.
Regards,
JC
Copy link to clipboard
Copied
Hi.
Do you need to move your object while the cursor is moving or only when you press the mouse left button?
Also, where the registration point of your girlMc instance is located? Top left, center...?
Regards,
JC
Copy link to clipboard
Copied
i need move object while the cursor is moving .registration point of girlMc in top left
Copy link to clipboard
Copied
Hi.
You can use:
import flash.events.Event;
function mouseMoveHandler(e:Event):void
{
girlMc.x = mouseX;
if (girlMc.x < 0)
girlMc.x = 0;
else if (girlMc.x > stage.stageWidth - girlMc.width)
girlMc.x = stage.stageWidth - girlMc.width;
}
stage.addEventListener(MouseEvent.MOUSE_MOVE, mouseMoveHandler);
I hope this helps.
Regards,
JC
Copy link to clipboard
Copied
thank you so much its work
Copy link to clipboard
Copied
You're welcome!