0 Replies Latest reply on May 5, 2011 7:08 AM by broconne

    Changing State/Line Drawing

    broconne Level 1

      I have a function that draws a line between two objects:



      private function drawLine(from:UIComponent, to:UIComponent, line:Line):void{


      var globalFrom:Point = from.parent.localToGlobal(new Point(from.x,from.y));



      globalFrom = pointAdd(globalFrom,findBottomCenterDifferential(from));

      trace("From Point: " + globalFrom);



      var globalTo:Point = to.parent.localToGlobal(new Point(to.x,to.y));



      globalTo = pointAdd(globalTo,new Point(centerX(to),0));

      trace("To Point: " + globalTo);


      var fromPoint:Point = line.parent.globalToLocal(globalFrom);

      var toPoint:Point = line.parent.globalToLocal(globalTo);










      I call this method 3 times and it works perfectly.  It essentially draws a line from the bottom center of the from component to the top center of the to component.


      Once that is complete, I begin a state change in which I add a new component to the HBox that contains the other three "to" components.  Once the transition to the new state is complete, I attempt to draw a line (#4) between the same from component to the new element added to the HBox.  I am using the same method to draw the line as before.. However, the line seems to be shifted 50 pixels or so to the left.  I log the "To Point" and based on loading the image in GIMP, I can see the global too point is accurate, however, it seems the translation to local is off for this 4th line.  Any pointers as to why it worked for the first 3, but after a state change (every item stays during the state change, only new items added, non deleted), the globalToLocal doesn't seem to reflect the proper X coordinate?