all groups > flash actionscript > march 2005 >
You're in the

flash actionscript

group:

line break from XML


line break from XML andros
3/1/2005 9:10:42 PM
flash actionscript:
linebreak brought in from XML does not work. this is the line from the XML:
blurb='some\r\nstuff' I have also used: blurb='some\rstuff' It
is displayed in a textfield which if i was to use actionscript to supply the
text 'some\rstuff' it would have a line break...but brought in from XML...it
displays as it is written. Is there an XML decode process ? The textfield is
not set to html and multiline is turned on. Any thoughts?
Re: line break from XML NSurveyor
3/1/2005 11:02:17 PM
When flash loads text which contains the backslash character, it will treat it
like an "actual" backslash. So in Flash, if you wanted to use the literal
backslash, you would use \\ to escape it. So, basically you're \r is really
\\r. Then, all you need to do is split the text on the \\r and join it on \r.
Same goes for \n. For example:

For,

blurb = "some\r\n\stuff"

You could use:

blurb = blurb.split('\\r').join('\r').split('\\n').join('\n');
Re: line break from XML andros
3/1/2005 11:05:09 PM
I did not get the /r to work correctly when bringing it in from XML..but i
was able to work around it by: creating the XML from the mysql database using:
urlencode($row['blurb']) to encode it first before generating the
XML.. then once it is brought from the XML into flash i use:
unescape(blurb) to allow for the line breaks. This is not uptimal for me
as the XML has a lot of extra urlencoded jargon in it. I am still looking for
a way to use the replacement of %0D for \r which has worked for me in the
past but while loading it from XML. Any thoughts about this would be a great
help.. i am new to the XML end of things
Re: line break from XML andros
3/1/2005 11:59:28 PM
Thanks NSurveyor I had sent that reply before I got your message. Turns out
though that the problem isn't so much at the Flash end as it is in the XML. The
generated XML can't handle the linebreak...it stops there. So I guess I will be
using the method I described above to encode the Blurb within the XML so it
will parse it...that is unless someone has knowledge as to retaining linebreaks
in XML . Perhaps I will start another thread based on that topic in a day or
two if no replies come in. Thanks again though.. that was good info for me!
Re: line break from XML andros
3/2/2005 12:09:38 AM
I realize what I said above isn't entirely accurate.. The XML generated from a
PHP query from a mysql database which contained text which had a linebreak in
it..DID NOT just stop at that point as i said above.. rather it looked like
this: blurb='corned beef on rye' There is a line break after beef but you
would not know it by looking at the XML. After I bring that into Flash it
stops parsing it at that spot. Now if i urlencode the blurb before it
generates the XML... it looks like this: blurb='corned+beef%0Don+rye' And
That works fine once brought into flash. Hope that helps clear it a little
better.
AddThis Social Bookmark Button