• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 5571
  • Last Modified:

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{

Open in new window

  • 2
1 Solution
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.
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 ?
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.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Easily Design & Build Your Next Website

Squarespace’s all-in-one platform gives you everything you need to express yourself creatively online, whether it is with a domain, website, or online store. Get started with your free trial today, and when ready, take 10% off your first purchase with offer code 'EXPERTS'.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now