What is a good strategy for detecting when the position (x, y) of a sprite, relative to the stage, has changed? In other words, how can I detect changes to a sprite’s global position?
This becomes difficult when the sprite is the child of other DisplayObjectContainer objects.
Is it a
UIComponentor just aSprite? I’m not sure how to do it if it’s just aSprite, but if it’s aUIComponentit’s doable, but could get messy.You’d have to listen to the component’s move event. When you get that event you can get its position and convert that to global coordinates using the localToGlobal() method.
Unfortunately I think you’d have to also listen to
moveevents for all of its parent components as well, as I don’t think a component will raise themoveevent if its parent moves.There might be a cleaner way to do this, but if not this should work.