I only really need the HBox answer but figure that if we get a good answer in here it would help anyone trying to do a similar thing with a VBox. It would be nice to know this in both actionscript and MXML.
So I have an HBox that I want some text aligned from the left and some radios from the right. Like so:
___________________________________________________
| |
|Text Yes () No() |
|___________________________________________________|
I am currently doing this by having an invisible box with a width of 100% between the text and the radios, like this
_____ __________________________________ ________________
| | | |
|Text | invisible box percentWidth=100; | Yes () No() |
|_____|__________________________________|________________|
I would prefer to just have the radios in their own HBox that is right aligned like this:
_____ ________________________________________________________
| | |
|Text | Yes () No() |
|_____|________________________________________________________|
I’ve seen some posts talk about a horizontalAlign property, but I don’t see it in the documentation anywhere.
So how can I accomplish this?
Thanks
~mike
There is a
horizontalAlignproperty, and averticalAlignproperty, on the VBox and HBox components (it’s inherited from Box). They determine the horizontal and vertical alignment of the component’s children.I generally use the Spacer object, like Sam mentions. But for what you want to do, this will work great.
In MXML you could do something like:
Note that the HBox with the
horizontalAlignset has to have a width value, otherwise, it will only be wide enough to accommodate the width of its children, in which case alignment is moot.Here’s an AS version: