# localToGlobal doubles x and y!

**URL:** <https://forum.kirupa.com/t/localtoglobal-doubles-x-and-y/298298>\
**Category:** Uncategorized\
**Created:** [October 16, 2009, 6:16am UTC](https://forum.kirupa.com/t/localtoglobal-doubles-x-and-y/298298 "2009-10-16T06:16:42Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Shaedo](https://avatars.discourse-cdn.com/v4/letter/s/e19b73/32.png) [@Shaedo](https://forum.kirupa.com/u/Shaedo)\
**Post date:** [October 16, 2009, 6:16am UTC](https://forum.kirupa.com/t/localtoglobal-doubles-x-and-y/298298/1 "2009-10-16T06:16:42Z")

</div>

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()](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

```auto
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.
