views:

4084

answers:

2

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.

+1  A: 

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.

davr
A: 

The passed width is in pixels.

I previously had some problems with not being able to style the label with CSS (at least I couldn't figure out how), so went with a regular textfield. Was a bit of a hassle to get the aligning just right, so I was hoping it was possible to move back to just the component.

I've been banging my head for two-three hours now, so I think it's back to a regular textfield again for me...