是否有可能将图像存储在Flash的共享对象?有可能、图像、对象、Flash

2023-09-08 12:16:20 作者:我们年轻就是资本

是否有可能存储图像在Flash中的共享对象?这将是很好,如果这是可行的。我需要存储局部图像,但它似乎并没有由Flash支持......所以我LD喜欢把中可以保存一个共享对象的图片...但它与图像的工作?

我试过跟一个位图,但如果我想读并把它添加到舞台上面说的对象不能转换为位图...

  VAR图像:位图= //一些真棒图像;

共享对象= SharedObject.getLocal的(IMG);
sharedObject.data.img =图像;
的SharedObject.flush();
 

下面的错误 - >

 共享对象= SharedObject.getLocal的(IMG);
的addChild(位图(sharedObject.data.img));
 

解决方案 怎样下载 保存 flash

在这种情况下,你需要写你的位图转换为ByteArray(换句话说 - 二进制数据),然后再设置你的共享对象。然后,你需要从ByteArray中读入位图,当你找回它。这里是一个快速样品希望将让你在正确的方向移动:

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

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

解决方案

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