0

When working with CSS inside of XML such as

<span class="IwuvAS3"></span>

when parsed in flash, if I don't use CDATA like the following:

<![CDATA[<span class="IwuvAS3"></span>]]>

then the parsed data drops down a line for every "<" character it sees.

When parsing the data into a single-line text field, nothing was shown because it was actually down a line. Soon as I wrap it inside of CDATA it works great. I have played with prettyIndent, and as I understand ignoreWhite is true by default.

Is there a way to parse the data without the use of CDATA and keep the implied line breaks out?

EDIT 1 (10/10/08): Thank you, but I am actually looking for a Function or Method. Escaping each is much more cumbersome than using CDATA. The only reason I don't want to use CDATA is that I was taught to stay clear of it. If ActionScript has a method associated to E4X XML handling that will remove the requirement to wrap my XML in CDATA, I would love to know about it.

EDIT 1 (10/15/08): Thanks Philippe! I never would have thought that HTML formatting in Flash is treated as whitespace. The answer was

textField.condenseWhite = true;

<3AS3

Brian Hodge
  • 2,125
  • 2
  • 19
  • 29

2 Answers2

3

Set the TextField's condenseWhite property to true - so only < br/> tags will generate linebreaks.

Philippe
  • 2,621
  • 1
  • 19
  • 20
  • Thanks alot, I never would have thought flash would treat the stuff as white space. This worked perfectly! CDATA IS EVIL! – Brian Hodge Oct 15 '08 at 20:35
  • span itself doesn't add whitespace, but Flash automatically reformats XML when it is converted to text. So XML nodes and text elements get indented - additional whitespace comes from this indentation. – Philippe Oct 16 '08 at 20:25
0

You could escape the "<" characters (and &, ", >, ', among others) as entities instead.

Joel Coehoorn
  • 399,467
  • 113
  • 570
  • 794