Hi,
I'm trying to figure out stage coordinates (x,y) so I can have an object in a legend move when an object in a picture is clicked.
Thanks
Hi,
I'm trying to figure out stage coordinates (x,y) so I can have an object in a legend move when an object in a picture is clicked.
Thanks
If I understand your question correctly... ...one solution is to add a MouseEvent Listener to the stage and then access the stageX and stageY properties of the event. For example:
(I apologize that I'm a little too busy at work right now to test this code but something along these lines should work.)
stage.addEventListener(MouseEvent.CLICK, handleClick);
private function handleClick( event:MouseEvent ):void {
var x:int = event.stageX;
var y:int = event.stageY;
var whatWasClicked:Object = event.target;
//do things with x,y depending on what the target is
//something like
//if(whatWasClicked is MovieClip){
// (whatWasClicked as MovieClip).x = 200;
//}
}
Of course, you don't have to add the event listener to the stage. You could add it to any relevant object. The parent object of your picture elements might be ideal. You get the stageX/stageY from any MouseEvent.
Hope that helps someone, -Kevin