2
votes

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?

Thanks in advance,

Amanda

2

2 Answers

2
votes

to change wordwrap to false, there has to be text set. ( i needed about half an hour to get it working!)

field.wordWrap = false;
trace(field.wordWrap); // will echo true

this following should work:

if(field.text == ""){

  field.text = "a";
  field.wordWrap = false;
  field.text = "";

} else {

  field.wordWrap = false;

}

trace(field.wordWrap); // should echo false
0
votes

First off, have you tried: this.field = new TLFTextField();

You didn't have the parenthesis.

At least worth a look at. (Also I believe this is Beta currently so there is a possibility of a bug?)

Finally, you might consider testing this without the AutoSize... sometimes causes problems.

Sorry that I can't be a little more helpful with an exact solution.