I have a litle problem. I have Hbox with label component in
it. When I change the label text, hbox size is automatically
changed after all code is performed. But how to find out Hbox size,
or label size (for example width) once after I change the text
property of the label... For example...
var myHbox:HBox = new HBox();
var myLabel:Label = new Label();
now the Hbox and lablel width and height is equal to zero.
Now I change:
myLabel.text = "Some Long Text"
But now if I want determine actual size of label or hbox
size, it is always zero.
How can I determine the size at once, when I change the label
Once you've made the changes to the child components, the
Flex framework goes through an iteration of measuring the children
and setting the HBox's new size.
You've got a couple of choices. First, once you've set the
size of the Label you can do: myHbox.validateNow() and then use
myHbox.getExplicitOrMeasuredWidth() (there's a Height version, too)
to get the HBox's new size. This doesn't allow the natural Flex
framework process to flow, but it should do the trick.
You could also try adding an event listener for the resize
event on the HBox. If the changes to the child cause the HBox to
have its size changed, it should trigger a resize event.