Once I've set either the width
or percentWidth
property on a flex label, is there a way to reset the width to its default (i.e., the width of the text plus padding)?
I'm using the label as a renderer. In some cases, I'd like it to automatically size to the text, and in other cases, I'd like it to be a percentage width of its container. Obviously, I could use two separate labels, one for each of the above cases, but I'm curious if it's possible to reset the label to its default behavior.
label.width = NaN;
//not sure if the following lines are required
label.invalidateSize();
label.width = label.measuredWidth;
From flex livedocs
When you set a specific height and width of a component, Flex does not call the measure() method, even if you explicitly call the invalidateSize() method. That is, Flex only calls the measure() method if the explicitWidth property or the explicitHeight property of the component is NaN.
Set the width to undefined:
yourLabelId.width = undefined;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With