I am a bit lost on how the various coordinate spaces in flex interact. I have an two objects, the second object is to the right and down from the first object. I want to create a move event that moves the first object right above the second, essentially centered over it. Based on what I read, I figured it would be pretty simple - and here is the method I came up with:
var Object1Point:Point = new Point(Object1.x,Object1.y);
var Object1Global:Point = Object1.localToGlobal(Object1Point);
var Object2Global:Point = Object2.localToGlobal(new Point(Object2.x,Object2.y));
var Object2CenterGlobal:Point = new Point(Object2Global.x + (Object2.width/2),Object2Global.y + (Object2.height/2));
var move:Move = new Move();
move.target = selectedRam;
move.xBy=Math.abs(Object2Global.x - Object1Global.x);
This puts the object much further over to the right than it should be - so clearly I am not understanding how these spaces interact. Any suggestions on how to relate these two spaces would be appreciated.
var Object1Point:Point = new Point(0,0);
The x,y of a component is its position relative to its parent.