May 25, 2006

Base64 Encoding for ActionScript 3/Flex 2.0

I updated this Base64 Encoder to work with ActionScript 3 for Flex 2.0 Beta 3.

New version:  Base64.zip

Also, there’s this version, which is binary data oriented:

Note that I’ve only done rudimentary testing with these.   It may not work perfectly.

11 Comments »

  1. Cool. Thanks!

    One question, though: doesn’t AS 3.0 have a native Base64 encoder? :D

    Comment by Jason Nussbaum — May 25, 2006 @ 6:50 pm

  2. Heh. I felt really stupid for a while, but I just checked the Actionscript 3.0 docs at the Adobe site, including the corelib documentation, and I can’t find anything that indicates native Base64 support in AS3.

    Comment by jb — May 25, 2006 @ 9:21 pm

  3. I’ve officially lost my marbles. I definitely saw that - it was there. Beta 1 or 2. Or alpha.

    I have no idea where it’s gone.

    So, ignore my question. Blame it on the lack of marbles. :)

    Comment by Jason Nussbaum — May 26, 2006 @ 1:11 pm

  4. Actually, I have discovered by looking at CoreLib that it is there in the code - (mx.util.Base64Encoder), but it is not in the documentation.

    Comment by jb — May 26, 2006 @ 1:32 pm

  5. Like I said, I know I’d seen it…and there were docs for it at one point in time, but they’re very gone now. Oh well.

    Comment by Jason Nussbaum — August 2, 2006 @ 2:43 pm

  6. thanks jb

    Comment by markas read — December 8, 2006 @ 9:22 pm

  7. How Can I display that Image on webpage. Can I bind to Image control? After Decoding?

    Comment by Jason — January 16, 2007 @ 6:37 pm

  8. Sorry, what do you mean?

    Comment by jb — January 16, 2007 @ 7:07 pm

  9. I used the Base64 encoder provided in the article, but the encoded string is not divisible by 4. All Base64 encoded strings should be divisible by 4 so this does not work when you encode and call a Java webservice, since it will complain that “java.lang.IllegalArgumentException: Length of Base64 encoded input string is not a multiple of 4.”

    Comment by Vinod — June 14, 2007 @ 3:16 pm

  10. Great, but I have a question. Why it is encoding (or decoding) the non-english letters wrong.
    I input this string: “Mókamaki mizériája” and I recive this one after encoding and decoding: “Mkamaki mizrija”? I lost all my “special” characters…

    Comment by SzyTamas — September 16, 2007 @ 3:15 pm

  11. If you’re just base encoding strings, you can easily use Flex’s existing classes. Look to the encode, and flush methods. I mention it on my blog, but found the classes thanks to you !!!

    Comment by LEE — October 11, 2007 @ 7:10 am

RSS feed for comments on this post. | TrackBack URI
You can also bookmark this on del.icio.us or check the cosmos

Leave a comment

XHTML ( You can use these tags): <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> .