Note that there are some explanatory texts on larger screens.

plurals
  1. POremoving whitespaces in ActionScript 2 variables
    text
    copied!<p>let's say that I have an XML file containing this :</p> <pre><code>&lt;description&gt;&lt;![CDATA[ &lt;h2&gt;lorem ipsum&lt;/h2&gt; &lt;p&gt;some text&lt;/p&gt; ]]&gt;&lt;/description&gt; </code></pre> <p>that I want to get and parse in ActionScript 2 as HTML text, and setting some CSS before displaying it. Problem is, Flash takes those whitespaces (line feed and tab) and display it as it is.</p> <pre><code>&lt;some whitespace here&gt; lorem ipsum some text </code></pre> <p>where the output I want is</p> <pre><code>lorem ipsum some text </code></pre> <p>I know that I could remove the whitespaces directly from the XML file (the Flash developer at my workplace also suggests this. I guess that he doesn't have any idea on how to do this [sigh]). But by doing this, it would be difficult to read the section in the XML file, especially when lots of tags are involved and that makes editing more difficult.</p> <p>So now, I'm looking for a way to strip those whitespaces in ActionScript. I've tried to use PHP's <code>str_replace</code> equivalent (got it from <a href="http://snipplr.com/view/3369/strreplace/" rel="nofollow noreferrer">here</a>). But what should I use as a needle (string to search) ? (I've tried to put in <code>"\t"</code> and <code>"\r"</code>, don't seem to be able to detect those whitespaces).</p> <p>edit :</p> <p>now that I've tried to throw in <code>newline</code> as a needle, it works (meaning that newline successfully got stripped).</p> <pre><code>mystring = str_replace(newline, '', mystring); </code></pre> <p>But, newlines only got stripped once, meaning that in every consecutive newlines, (eg. a newline followed by another newline) only one newline can be stripped away.</p> <p>Now, I don't see that this as a problem in the <code>str_replace</code> function, since every consecutive character other than newline get stripped away just fine.</p> <p>Pretty much confused about how stuff like this is handled in ActionScript. :-s</p> <p>edit 2: </p> <p>I've tried str_replace -ing everything I know of, \n, \r, \t, newline, and tab (by pressing tab key). Replacing \n, \r, and \t seem to have no effect whatsoever.</p> <p>I know that by successfully doing this, my content can never have real line breaks. That's exactly my intention. I could format the XML the way I want without Flash displaying any of the formatting stuff. :)</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload