是否可以将图像存储在 Flash 的 SharedObject 中? [英] Is it possible to store images in the SharedObject of Flash?

查看:19
本文介绍了是否可以将图像存储在 Flash 的 SharedObject 中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在 Flash 的 SharedObject 中存储图像?如果它可以工作就好了.我需要在本地存储"图像,但 Flash 似乎不支持它...所以我想将这些图像放在可以保存的 SharedObject 中...但它可以处理图像吗?

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

此处出错 ->

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

推荐答案

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

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

这篇关于是否可以将图像存储在 Flash 的 SharedObject 中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆