Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to store images in the SharedObject of Flash?

Is it possible to store a Image in a SharedObject in Flash? It would be nice if it would work. I need to "store" Images locally but it seems not to be supported by Flash... So I 'ld like to put those images in a SharedObject that can be saved... but does it work with images?

I tried it with a Bitmap but if I want to read and add it to the stage it says that the Object can't be converted to a Bitmap...

var image:Bitmap = //some awesome image;

sharedObject = SharedObject.getLocal("img");
sharedObject.data.img = image;
sharedObject.flush();

Error here ->

sharedObject = SharedObject.getLocal("img");
addChild(Bitmap(sharedObject.data.img));
like image 685
Hank Avatar asked Sep 28 '09 11:09

Hank


People also ask

Can a flash local shared object be deleted?

Users can opt out of LSOs from specified sites from Flash Player's "Settings", accessed by right-clicking the Player, or using the Website Storage Settings panel; the latter also allows users to delete local shared objects. Users may also delete local shared objects either manually or using third-party software.


2 Answers

In this case, you need to write your Bitmap to a ByteArray (in other words - binary data) before you set your shared object. Then you need to read it from a ByteArray into a bitmap when you retrieve it. Here is a quick sample the hopefully will get you moving in the right direction:

http://www.kirupa.com/forum/showthread.php?t=306972

like image 155
David Tucker Avatar answered Nov 09 '22 03:11

David Tucker


Don`t forget, shared object has limited size (100Kb default)

like image 21
peko Avatar answered Nov 09 '22 02:11

peko