Aligning text according to width


(Mohamed Atef) #1

Iam trying to make something like a message box , but my problem is that I cant make the text be in multiple lines , only in one line , and its a long text so it goes after the window very much , so I want either make the window resize according to text or vise versa ( text starts another line when it reaches the end of the window would be better ) . I hope I could explain my problem well but Iam on a real rush .


(Justin Wolf) #2
text.wordWrap = true;
text.width = 200;
text.text = "Really long string, long string, yes it's a very long string.";

You have to set a static width of your Text and set wordWrap to true. It now will wrap after the text has reached the width of 200px and continue on the next line.


(Mohamed Atef) #3

how can I access this property ,I cant find it in the Text object .


(Justin Wolf) #4
var text:Text = new Text("My text");
text.wordWrap = true;

Does that not work?


(Jacob Albano) #5

Looks like wordWrap is a static property to be used for newly created Text objects. This should work:

text.setTextProperty("wordWrap", true);

(Justin Wolf) #6

Interesting. I must be using an outdated version of FP, because I can access wordWrap directly from text objects. Gotta update one of these days. :smiley:


(Jacob Albano) #7

Having it static feels very strange to me. I guess it would have caused a name collision otherwise, and setTextProperty() technically satisfies that need.


(Mohamed Atef) #8

setTextProperty kinda worked , it did the wordwrap but not according to the width and height which didnt made it fit very well , the weird thing is although I had FP 1.7.2 I had to re-download it because that method didnt exist , and that`s the second time I had to redownload the same version for some missing code .