views:

101

answers:

3

how to show a image with AS3 from source like:

"GIF89a,.,...... ..sR....8.d.4..p...%...h..'$W..." etc...

thanks in advance

Leo

A: 

I'm not sure of the format of your source, is it base 64? A URL?

If it is the image data itslef e.g. base 64, you need to create a BitmapData object and populate it using e.g. setPixel()

Iain
I need to send a picture to flash with external interface but do not know how ... can not be an url because don't have connection...I'm trying open the image file and send to flash like text but without success...
That doesn't sound possible, but good luck.
Iain
Leo, you know the path to the image because you want to send it from javascript via ExternalInterface. Why not just pass the url to that image to a Loader object, handle the Event.INIT and carry on from there ?
George Profenza
A: 

so you basically get the binary representation in a string, i guess?

you will need flash.utils.ByteArray and flash.display.Loader ... first you put the String into the ByteArray and then you can load the data as an image using Loader::loadBytes ...

getting the string into the ByteArray may lead to funny results, due to codepages ... there is ByteArray::writeMultiByte and ByteArray::writeUTFBytes ... sometimes i hate encoding, can't get my head around when to do what ... :D ... but i'd say it's the latter, since flash always interprets incoming strings as encoded in its codepage, which is utf8 by default (unless flash.system.System.useCodePage is set to true) ... so the incoming string should be utf8 decoded and to recover the same binary data, you need to utf8 encode it ... i think ... :)

base64 encoding it, would be the most secure way i guess ... there are ton's of base64 implementations for as3, so the only question is, whether you will be able to base64 it on js side ...

but in the end, it's faisible ... good luck ... ;)

back2dos
A: 

You can try the AS3 GIF Player by Thibault Imbert. I've used it on a school project two years ago. You can still see it in action here. If you just want to see GIF files loaded and played, press preview. If you want to save a gif, play with the frames in the timeline and the figure on the stage then press GET GIF.

George Profenza