Dynamically flip wordwrap property on TLF text field
Hi,
I tried posting this to Stackoverflow first, but no one has found a solution so I thought I'd try posting it here. I am using Flash CS5 and Actionscript 3.
I need to dynamically (in response to an event) flip the wordWrap property of a TLFTextField from true to false and vice versa. I had it working with the old TextField class, but I I can't get it to work with TLF.
I declare my field and set it up like so, with wordWrap set to true:
this.field = new TLFTextField();
field.multiline = true;
field.wordWrap = true;
field.autoSize = TextFieldAutoSize.LEFT;
field.tlfMarkup = my_content;
this.addChild(field);
var myTextFlow:TextFlow = field.textFlow;
myTextFlow.hostFormat = format; //format is a TextLayoutFormat declared earlier
myTextFlow.flowComposer.updateAllControllers();
To change the word wrapping, I've tried the following:
field.wordWrap = false;
field.multiline = false;
var myTextFlow:TextFlow = field.textFlow;
myTextFlow.flowComposer.updateAllControllers();
But this has no effect - the text stays wrapped. Can anyone tell me what I'm missing?
I do need the AutoSize.LEFT property in order to set the height of the field properly (I'm only specifying width, and need the height of the field to match the text exactly for some effects I'm doing). What I'm trying to achieve is shown below, where the lines indicate the bounds of the text field. I need to switch between states 1 and 2.
1.
______________________
|Here is some text. It is |
|word wrapped. |
--------------------------------------
2.
______________________
|Here is some text. It is wo|rd wrapped
| |
--------------------------------------
Thanks in advance,
Amanda
