Let's talk about Flex, AIR, ActionScript, ColdFusion and more    

Flex sample : Base64, JPEGEncoder, PNGEncoder


I created a sample of Base64, JPEGEncoder, PNGEncoder because I wanted Base64 text of a small image. It has grown bigger while I was making it.... So it might not be simple.

On making it, I found a bug of Base64Encoder.encodeBytes method.

// see encodeBytes in Base64Encoder.as
/* original code is below. This is wrong I think.
var plainIndex:uint = offset;

while (plainIndex < length)
*/
/* This should be below.
var plainIndex:uint = offset;

while (plainIndex < offset + length)
*/

The current third parameter of encodeBytes method doesn't mean "length" but it means "end of offset" to read bytes, I think.

BTW, I noticed we can't access to Loader.content after it's read bytes via Loader.loadBytes even if ApplicationDomain is same. Could not we do this before??


The sample is here.
ImageToBase64String




All Flex samples is here.
Flex samples

CF8 samples is here.
CF8 samples


Comments
Danny Miller's Gravatar Cool. But what does it do differently than the other base64 classes other developers have made?
# Posted By Danny Miller | 7/9/08 2:56 AM
Shigeru's Gravatar Hi, Danny. No difference:) It's just "Flex has Base64 API". So You don't need to search/find other one.
# Posted By Shigeru | 7/9/08 3:03 PM
BlogCFC was created by Raymond Camden. This blog is running version 5.5.005.