1

I am using flash External Interface to send media files from javascript to actionscript. However, sending the binary as a string causes unexpected problems. Presence of certain characters in the binary file causes the string to be received as null. One such character was ﷡ .

I tried using btoa() on the file but it failed with "invalid characters" within the js itself.

I have a flash application which need to make http calls with range request header. Since range header is not allowed in flash, I am using external interface on javascript but then stuck here.

4
  • How do you encode the string? You could use some safe ways like Base64, but the information could get pretty big (not sure if there is any limitation).. Commented Apr 9, 2014 at 8:29
  • As I said, I used btoa() which failed with error: Invalid characters. I also used an alternative base64 js library which did a toUtf() function before the actual encoding. However, I couldn't regenerate the actual data in actionscript. Commented Apr 9, 2014 at 11:17
  • As said in MDN: Please note that this is not suitable for raw Unicode strings!.. Maybe this: jsbase64.codeplex.com Commented Apr 9, 2014 at 11:51
  • That is what I referred as alternative base64 library. If you note it's source code, it calls toUtf() function before encoding converting a 100kb chunk to ~255kb. However in as3, a simple base64 deocode gave 199kb which on passing through a fromUtf() function (which I ported from the jsbase64 to as3) resulted in ~143kb. I couldn't get the original data back. Commented Apr 9, 2014 at 14:49

1 Answer 1

2

Had to write a few scripts to do this job. They basically encode the javascript array buffer into ascii characters and then decode them in actionscript. I am not sure how efficient these are.

https://gist.github.com/vibhavsinha/11344013

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.