Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Problem passing data from Javascript to Flex

I am using ExternalInterface in Flex to retrieve AMF encoded string from Javascript. The problem is the AMF encoded string sometimes contains \u0000 which causes the ExternalInterface to return null instead of the encoded string from Javascript.

Any idea how to solve this?

Thanks in advance.

like image 607
doorman Avatar asked Mar 18 '26 18:03

doorman


1 Answers

The \0000 is falsely interpreted as EOF when reading external data. The same thing happens when it appears in XML files, as well.

You should be able to replace it with an unambiguous character sequence before passing the string to Flash, and back upon reception in ActionScript. In the JavaScript function, use something like

return returnString.replace (/\0000/g, "{nil}");

This should remove the unwanted \0000 characters from the string before returning it to Flash.

On the Flash side, use

receiveString = receiveString.replace (/\{nil\}/g, "\u0000"); 

directly after receiving the data.

like image 100
weltraumpirat Avatar answered Mar 20 '26 08:03

weltraumpirat