1 Reply Latest reply on Feb 18, 2008 10:06 PM by Ratsnackbar

    X Coordinate inside of an HBox

    XXIlladelphia
      This is how I had to achieve this little tedious task!

      var newX:int = optionsHBox.x + 30*optionsHBox.getChildIndex(icon) - 10;

      basically, I had to get the x location of the HBox, then add 30 depending on the child index of the item I want the x coordinate of.

      Is there an easier way to do this? HBox.getChild().getX() would be awesome!!! ;)
        • 1. Re: X Coordinate inside of an HBox
          Ratsnackbar Level 2
          Well you could extend the HBox and add a method to iterate over the Children and calculate their value based on the index from within the method and then just pass the value back. It is not Easier but would allow you make the call to position the child in the way you want.

          If you really want to get fancy you could override the addChild or addChildAt method and have it call your method that calcs the position and sets the starting X and Y as it adds the child.