Flex has a Base64Decoder and Base64Encoder class.
http://opensource.adobe.com/svn/opensource/flex/sdk/trunk/frameworks/projects/framework/src/mx/utils/

The Base64Decoder class however depends on/uses mx.resources.ResourceManager, 
which in turn imports a few flex specific classes.

regards,
Muzak

----- Original Message ----- From: "Juan Pablo Califano" <[EMAIL PROTECTED]>
To: "Flash Coders List" <flashcoders@chattyfig.figleaf.com>
Sent: Saturday, April 26, 2008 12:15 AM
Subject: Re: [Flashcoders] Converting a ByteArray to string and back again...


A more compact and standard way to store binary data as text is using Base64
encoding (http://en.wikipedia.org/wiki/Base64).

You can find some AS 3.0 encoders around (try "googling" it).

Here's an implementation I wrote some months ago. So far, it has worked
smoothly (I've used to send binary data to php and .NET backends). Feel free
to use it as you see fit if you find it useful.

http://pastebin.be/10837

Cheers
Juan Pablo Califano

2008/4/25, John Eriksson <[EMAIL PROTECTED]>:

I've been messing around with the ByteArray for some time now, and I wonder
if there isa way to convert the ByteArray to a string (ie using toString())
and then converting that string
back into a ByteArray which would then be the same as the original
ByteArray.

This would mean I could include an AMF serialized object in an xml document
and later deserialize
it from that string in the xml...

Is this possible? ByteArray doesn't have a "fromString" method and I've
tried writeUTF and writeUTFBytes but that
doesn't seem to be right.

I did manage to get the bytes one by one from the byte array, creating a
string like "10,245,343,12.....",
and later doing some split() join() stuff to finally assemble the ByteArray
- but this seems a bit complex and
maybe even slow. Am I missing something? Can it be done much faster?


Kind regards,
John

_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to