I need to determine the global x and y for objects (ie x and y relative to the stage). I have been using localToGlobal to achieve this.
http://help.adobe.com/en_US/AS3LCR/Flash_10.0/flash/display/DisplayObject.html#localToGlobal()
This appears to work fine for objects that are in containers BUT it increases the x and y values for objects that are added directly to the stage!
How can I get the global X,Y for objects in and not in a container?
Do I have to check if (object.parent == MainTimeLine) ?
In case I am not makeing much sense here is some code to illustrate the effect
var Sprite1:Sprite = new Sprite();
Sprite1.x = Sprite1.y = 100;
addChild(Sprite1);
var local_point:Point = new Point(Sprite1.x,Sprite1.y);
var global_point:Point = (Sprite1.localToGlobal(local_point));
trace(local_point); // (x=100, y=100) //yes it is at 100, 100
trace(global_point); //(x=200, y=200) // NO! BAD FLASH! ???!?!? why double?!?
var Sprite2:Sprite = new Sprite();
var holder:Sprite = new Sprite();
holder.x = holder.y = 100;
addChild(holder);
holder.addChild(Sprite2);
local_point = new Point(Sprite2.x,Sprite2.y);
global_point = (Sprite2.localToGlobal(local_point));
trace(local_point); // (x=0, y=0) //yes locally it is at 0,0
trace(global_point); //(x=100, y=100) //yes globally it is at 100, 100
Thank you for your consideration,
S.