8 Replies Latest reply on Apr 29, 2011 11:14 AM by broconne

    localToGlobal - Just can't figure it out.


      Read through the forums, searched the web..  Still can't figure out how exactly localToGlobal works or in my case why it doesn't work:


      I have the following MXML:

      <mx:VBox id="LoadBalancer" paddingTop="20" verticalGap="20" horizontalAlign="center" width="100%" height="100%" includeIn="LoadBalancer">



      <mx:Image source="@Embed(source='internet_cloud.png')" scaleX=".5" scaleY=".5"/>

      <mx:Image source="@Embed(source='foundrysigtc.png')" scaleX=".2" scaleY=".2" id="foundry"/>




      <mx:HBox horizontalGap="20" id="LoadBalanceX">

      <mx:Image source="@Embed(source='x3650m2.png')" scaleX=".5" scaleY=".5" id="x1"/>

      <mx:Image source="@Embed(source='x3650m2.png')" scaleX=".5" scaleY=".5"/>

      <mx:Image source="@Embed(source='x3650m2.png')" scaleX=".5" scaleY=".5"/>




      <s:Line visible="false" id="line1">


      <s:SolidColorStroke color="red" alpha="1" weight="10"/>







      I want to draw a line between foundry and x1.  Eventually, I want to draw it from the center point, or the edge closest between the two of them.  For the test case, I just want to get it close.


      So, when I enter the state "LoadBalancer", my enterState function is set to:

      private function loadBalancer(): void {

      var node:Node = stepNodeMap[VIP];



      var foundryPoint:Point = new Point(foundry.x,foundry.y);

      var globalFoundryPoint:Point = foundry.localToGlobal(foundryPoint);




      var x3650Point:Point = new Point(x1.x,x1.y);

      var globalXPoint:Point = x1.localToGlobal(x3650Point);






      Now, I would expect to have two different points even if x1 and foundry are set to 0,0 in their own coordinate space..  But when I look at my log, I have this:






      There is something fundamental about coordinate spaces in flex that I can't grasp.  I think I am doing the right things.. But the results are not what I expect.    Any pointers?