Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This is apparently a known issue and it doesn't seems like Adobe is going to fix it anytime soon.</p> <p>I found a <a href="http://mihai.bazon.net/blog/externalinterface-is-unreliable">detailled explaination</a> of this problem and basicly the issue seems to be that Flash doesn't handle the <code>\</code> and the <code>&amp;</code> properly which can lead to javascript error or data corruption during the transfer from Flash to javascript.</p> <p>What Flash attempts to do when you transfer data from Flash to JS is to execute the following thing :</p> <pre><code>try { __flash__toXML(yourJavascriptFunction("[DATA]")) ; } catch (e) { "&lt;undefined/&gt;"; } </code></pre> <p>The problem is that it puts your data raw and it doesn't escape the backslash at all. If your string contains only <code>\</code> and you want to call <code>console.log</code> on it, it will try to do the following thing :</p> <pre><code>try { __flash__toXML(console.log("\")) ; } catch (e) { "&lt;undefined/&gt;"; } </code></pre> <p>As you can see this is invalid javascript. It will throws an error in your Javascript console and it will never call <code>console.log</code>.</p> <p>The solution is to either ducktape Flash behavior or do some nasty hack to get around it.</p> <p>To ducktape Flash buggyness you can escape the blackslash before you transfer them. This solution will work for now, but when Flash will fix it (most probably not in a near future, if you consider that this bug is known for more than 4 years), it will break your application.</p> <p>The other possibility is to url encode the character that Flash doesn't handle well (<code>\</code>, <code>"</code>, <code>&amp;</code>) and to decode them on the other side.</p> <p><strong>Flash :</strong></p> <pre><code>data = data.split("%").join("%25") .split("\\").join("%5c") .split("\"").join("%22") .split("&amp;").join("%26"); </code></pre> <p><strong>Javascript :</strong></p> <pre><code>data = data.replace(/%22/g, "\"") .replace(/%5c/g, "\\") .replace(/%26/g, "&amp;") .replace(/%25/g, "%"); </code></pre> <p>It's ugly, but it works.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

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