Search code examples
actionscript-3airadobe

localToGlobal Strange results in Adobe Air


Im getting a weird result with local to global which for the last 2 hours has nearly made me cry.

I'm trying to get the x of a child, of a child object, and it's coming back with strange minus numbers, where it should be a healthy positive number on the other side of the screen!

so I've got childObject in childContainer, and no variation of

 localToGlobal(new Point(childContainer.childObject.x,0)).x;
   or childContainer.childObject.localToGlobal(new Point(0,0)).x;
or childContainer.localToGlobal(new Point(childObject.x,0)).x;

Or anything similar is giving me a result I can use (i.m expecting something like 1100, and I'm getting -91);

I've tried taking this result away from the stageWidth, and it's close, but not really right.

Please help!


Solution

  • Thanks.

    The problem was timing. This was getting called before the parent had been added to the stage. School boy error.