Multi-line label in RadioButton component (AS3)

actionscript-3flashradio-buttonword-wrap

I'm making a small quiz-application in Flash (and ActionScript 3). Decided to use the RadioButton-component for radiobuttons, but I'm having some problems getting the word-wrapping to work.

The code for creating the button can be found below.

_button = new RadioButton();
_button.setStyle("textFormat", _format);
_button.label = _config.toString();
_button.width = Number(_defaults.@alen);
_button.textField.width     = Number(_defaults.@alen);
_button.textField.multiline = true;
_button.textField.wordWrap  = true;
_button.value = _config.@value;
_button.group = _group;
_button.x     = _config.@x;
_button.y     = _config.@y;

_config is a piece of XML, and _defaults is a piece of XML containing size-information and font-setup

When I set _button.textField.wordWrap to true, the text gets split into multiple lines, but it's not split at _defaults.@alen, which I want, but looks like it happens pretty much after each word.

Also, it sometimes splits it into several lines, but doesn't display it all until the mouse hovers over it.

Best Answer

Two possibilities: width should be in pixels, not in characters. In addition, don't forget that the button itself uses up some of the width.

If you can't get it to work, instead of banging your head on it, might want to just create the label separately, either a simple TextField, or using a Label component. Slightly more code, but might be worth it to spend an extra 10 minutes writing code versus two hours getting the component to work how you want.

Related Topic