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

别说谁变了你拦得住时间么 提交于 2019-11-28 01:12:46

问题


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));

回答1:


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




回答2:


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




回答3:


Images to/from SharedObject.data - easy, free and ready to use class which includes full SharedObject events and status logic: Images to/from SharedObject.data



来源:https://stackoverflow.com/questions/1486471/is-it-possible-to-store-images-in-the-sharedobject-of-flash

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!