Actually, from my tests (on the "component" I made, which was AS 3.0), the
bottle neck was not encoding to base 64 per se (as I assumed at first), but
assigning the resulting string to the LoadVars object (o URLRequest in my
case...). If I commented out that specific line, it worked way faster; when
the big string was assigned to the URLRequest, it took a while, even in AS
3.0 (I'm talking about really big images, perhaps some 1 MB string...)

In my "component" I used a mix of AS 2.0 and AS 3.0. The app was AS 2.0; I
got the raw pixel data and sent it to the AS 3.0 module (loaded in an
invisible frame) through a local connection (in various "passes" not just
the whole array because there's a limit, I think it's 40 Kb or something
like that).

Once I got the raw pixel data in the AS 3.0 module I converted it to jpeg,
then encoded it to Base64, and the post it to the server. It took a while to
get it right, but finally I got it working. Later I realized that the
URLRequest object lets you send binary data, so I avoided the base64
encoding step.

You're stuck with AS 2.0, so there are things you can't do. For instance,
posting binary data to the server. As far as I know, you just can send text,
using a LoadVars obj.

However, you can try to create the jpeg in the swf. I'm not saying it'll be
faster. Who knows. But maybe it's worth trying. I have a JPGEnconder class,
that can be ported to AS 2.0. The code is far from understandable to me, but
just adapting it to AS 2.0 seems feasible. The only thing missing is the
native ByteArray class, but it's not that hard to make one (in the end, it's
just a storage structure with a pointer / cursor and a few methods to make
it easier reading bytes, shorts, ints, etc).

So, I think the parts needed to give it a try are there. If you're
interested  I can post somewhere the Base64 class (AS 3.0, should be
ported), the ByteArray (might need to add some methods but already
reads/writes unsigned bytes and unsigned shorts), and a Base64 encoder (AS
2.0, too, I've used to some extent and works fine).

What I was thinking, to sum things up, is this:

* get the raw image data into a ByteArray
* encode that data to create a JPEG image in memory
* encode that image data to base64
* post the resulting string to the server

Might or might not cut it, haven't tried it as I said, and that's really the
only way to know.

If you want to use some of the code I mentioned to give it a try, just let
me know.


Cheers
Juan Pablo Califano

2008/2/4, Dave Mennenoh <[EMAIL PROTECTED]>:
>
> > you're sending a comma separated string to the server?
> >
> > why not have 2 hey digits for all the data and omit the comma? this
> would
> > bring your data to 2/3 of its size, which means 26sec*2/3 = 17.3sec
> >
> > when this works, you could try to send binary data - so instead if
> sending
> > the string "ff" you would send the binary byte 255. if this works, this
> > would cut the time in half again => 8.6sec
> >
> > if you can't create binary data, you could still use base64 encoding
> > instead, which would give you 8.6*1.33 = 11.5sec.
>
> Yeah, I'm sending an array of colors. What's a hey digit? And it's not FF,
> that was just an example, it's colors so it's FFFFFF or 16777215 as an
> integer and it's not any faster to send as integers, in fact I found it a
> little slower so am sending the hex string. Keeping in the commas just
> makes
> it easy to reconstruct the image since if an array index is null I just
> use
> the last good color. I did say it was simple. :) I'll definitely give
> base64
> a shot. I'm stuck with AS2 here so I didn't think I could do binary, but
> Juan seems to say it's possible.
>
> Thanks
>
> Dave -
> Head Developer
> http://www.blurredistinction.com
> Adobe Community Expert
> http://www.adobe.com/communities/experts/
>
> _______________________________________________
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to