Skip to main content
August 12, 2011
Answered

AS3: organized text blocks

  • August 12, 2011
  • 1 reply
  • 839 views

Hey,

I have a problem regarding text appearence on screen.

I have few TFL dynamic text fields in CS5.5 that update each time according to users choises (a dictionary, in hebrew if it matters).

As a text field I can't break lines or organize the text in paragraphs or any other way, the corrent situation is a text block that is not pleasent to read, it's need to be organized (it's for children so it has to be as clear as possible).

I used + '\n' + and it worked with a test file but it didn't on my real project. When testing it throws "can not assign a non refernec value : Erroe 1050".

I am desperet! is there a way to orgenize my text as a dynamic text field? or is there another way?

Any help will be really apprecieted.

This topic has been closed for replies.
Correct answer Ned Murphy

I don't have a new enough version to test that with TLF textfields, but using a normal textfield the code tests fine.

If you are adding that text all at once using code, then you should keep it on one line just to be safe, though it should work separated.  And you can use doublequotes around all portions of it, no need for single quotes around \n's.

If you are adding it in stages, you should use the appendText() method.

Since the error is indicating something cannot be assigned to the textfield, it would seem that there is something amiss with the textfield, so you might try placing:  trace(elderText);  one line before to see if it indicates it is recognized as a TLFTextField.

1 reply

Ned Murphy
Legend
August 12, 2011

Can you show your code.  Have you tried it using classic tetfields instead of TLF?  One other thing you should do is go into your Flash Publish Settings and select the option to Permit Debugging.  That might help by identifying the number of the line of code from which the error arises.

August 12, 2011

This is an example to my code, exept my text is in hebrew. elderText.text is a TLF dynamic text box that was created on stage and not by AS, although text change is doen in AS3. The error refers to this line.    

elderText.text = "line1 line1 line1" + '\n' +

                         "line2 line2 line2" + '\n' +

                         "line3 line3 line3"

I need to use TLF because my text is hebrew and otherwise the text gets messed up.

Can you give me an example to how a code like this should look? Maybe I am doing somthing wrong somewhere I don't know.

Thanks.

Ned Murphy
Ned MurphyCorrect answer
Legend
August 12, 2011

I don't have a new enough version to test that with TLF textfields, but using a normal textfield the code tests fine.

If you are adding that text all at once using code, then you should keep it on one line just to be safe, though it should work separated.  And you can use doublequotes around all portions of it, no need for single quotes around \n's.

If you are adding it in stages, you should use the appendText() method.

Since the error is indicating something cannot be assigned to the textfield, it would seem that there is something amiss with the textfield, so you might try placing:  trace(elderText);  one line before to see if it indicates it is recognized as a TLFTextField.