-
XML text problem
When you want to have linebreaks in a multiline text in AS you should write this, right?
Code:
var mytext:String="This is \nwhat \nI want";
so you have a 3-line text. ok, so i have a textfield, and its content will be loaded from a xml file. in my xml i have something like this:
Code:
<mytext>This is \nwhat \nI want</mytext>
then, when i load the file and assign that node to the .text property of my textfield it doesn't recognize the linebreaks. I had no trouble loading and working with the rest of the data. i just want to include the linebreaks in the xml, but i don't know how. i also tried casting the type of variable to string, tried using the toString() method of the xmllist and nothing.
How can i solve this? any ideas??
Last edited by nazcaline; 01-15-2009 at 02:19 PM.
-
i use cdata and normal line breaks (not "\n")
PHP Code:
<message><![CDATA[line 1.
line 2.
line 3.]]></message>
-
but that's php code, i'm not using php. it's a simple xml file in my local folder where i keep the info for the swf i'm making. is there an easier way to do this??
thanks anyway for your help, man
-
could it be your using a \ instead of a /?
I believe / are command line operators while \ is for say linking or something of that nature. Hence why sometimes you have to do // its to let the compiler know that you don't want the command line operator.
-
that's not php. it's xml. try it.
-
moagrius:
it worked. but it worked too without cdata, i just did:
<
Code:
mytext>This is
what
I want</mytext>
the problem now is that the separation between the lines is just too much (with cdata or without it). i fixed it with the .leading property of the textFormat class, i had to put it at -4. isn't this weird??
-
yeah i've noticed that too, and will use leading when it looks off - the amount depends on the font.
fyi, cdata is just used for "safe" data... it lets you used otherwise prohibitive characters (like you'd find in html), e.g.,
PHP Code:
<message><![CDATA[line 1.
<a href="page.html">link</a>
line 3.]]></message>
without the cdata markers, it'd interperet the html as another xml node. when writing xml dynamically, i tend to always use it just in case - but you're right, for simple text like you have it's not necessary.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|