Don’t forget the wordWrap!
Posted by admin | Filed under Flash
Quick post time. I was working in Flash today creating some text fields at run time and populating them with text. I set the width, made it multiline and then dropped in the text using code similar to the snippet below.
var contents = new TextField();
contents.width = 300;
contents.multiline = true;
contents.text = myData;
Tested the movie and shocker, the text was not multiline! Confused I read the lines over and over again, changed the order in which I declared the multiline value and then it hit me, word wrap! By default the wordWrap value in Flash is set to false, this forces all the text on one line no matter what the multiline says. By adding a simple wordWrap = true everything displayed as intended.
var contents = new TextField();
contents.width = 300;
contents.wordWrap = true;
contents.multiline = true;
contents.text = myData;
I’m not sure why I always forget the wordWrap but next time I do hopefully I remember I wrote this post!
Tags: AS3








