Flash的SharedObject中可以存储图片吗?

发布于 2024-08-06 04:32:56 字数 475 浏览 3 评论 0原文

是否可以将图像存储在 Flash 的 SharedObject 中?如果能行的话那就太好了。我需要在本地“存储”图像,但 Flash 似乎不支持它...所以我想将这些图像放入可以保存的 SharedObject 中...但是它可以处理图像吗?

我用位图尝试过,但如果我想读取并将其添加到舞台上,它会说该对象无法转换为位图...

var image:Bitmap = //some awesome image;

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

此处错误 ->

sharedObject = SharedObject.getLocal("img");
addChild(Bitmap(sharedObject.data.img));

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

地狱即天堂 2024-08-13 04:32:57

在这种情况下,您需要在设置共享对象之前将位图写入 ByteArray(换句话说,二进制数据)。然后,当您检索它时,您需要将其从 ByteArray 读取到位图中。这是一个快速示例,希望能让您朝着正确的方向前进:

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

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

翻了热茶 2024-08-13 04:32:57

不要忘记,共享对象的大小是有限的(默认为 100Kb)

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

腹黑女流氓 2024-08-13 04:32:57

往返于 SharedObject.data 的图像 - 简单、免费且随时可用的类,其中包括完整的 SharedObject 事件和状态逻辑:
向/从 SharedObject.data 的图像

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文