difference between stageX and localX in AS3

in the following piece of code. I am unable to understand the difference between stageX and localX. i have experimented a little but couldnt figure out. I would greatly appreciate if someone can reply quickly. Thanks !


stage.addEventListener(MouseEvent.CLICK, reportClick); 
function reportClick(event:MouseEvent):void{
 trace(event.localX+","+event.localY);
 trace(event.stageX+","+event.stageY);
}

Open in new window

LVL 2
whatisittellmeAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

blue-genieCommented:
in that particular instance, the 2 values will always be the same as the stage doesn't have a containing sprite.
if you were adding a listener to an item you could then get the items coordinates  for that item relative to the stage.
does that make sense?

localY The vertical coordinate at which the event occurred relative to the containing sprite.

stageY The vertical coordinate at which the event occurred in global stage coordinates.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
whatisittellmeAuthor Commented:
I have added advanced flash component to the stage. but i am not sure where the origin of that component is. i do get different values for (localX,localY) and (stageX,stageY). how do i find out where is another origin (other than that of the stage) is ?

also, what is a sprite ?
0
blue-genieCommented:
AS3 introduced the display list.
A sprite is of the DisplayObjectContainter class. so your sprite may contain a button and an image and other items.

remember that you have a local coordinates for an item, and you have it's coordinates based on the x and y of the stage.
in AS2 there was the localToGlobal and globalToLocal option.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Adobe Flash

From novice to tech pro — start learning today.