如何共享在Adobe AIR不同页面之间的JavaScript对象? [英] How do I share a javascript object between different pages in Adobe AIR?

查看:446
本文介绍了如何共享在Adobe AIR不同页面之间的JavaScript对象?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想有附加到应用程序中的自定义对象,所以我可以preserve状态,它在Adobe AIR不同的HTML页面之间。这可能吗?

I'd like to have a custom object attached to the application so I can preserve state in it between different html pages in adobe air. Is this possible?


我要求的睡解决方案来存储自定义JS对象在内存中,坚持从应用程序沙箱加载页面之间,但是这不能做,除非我使用iframe这是不是很愉快,因为我有添加很多东西的桥梁。 Anoter方式可能是做填充HTML从文件中读取页面的部分呈现,但暴露了很多不愉快的错误+你不能写动态脚本标记在DOM。这是一个残缺的平台。

I was asking for a fullblown solution to store a custom js object in memory and persist it between pages loaded from the application sandbox, but this cannot be done unless I use iframes which is not very pleasant, since I have to add a lot of stuff to the bridge. Anoter way may be to do partial rendering of the page filled with html read from files, but this exposes a lot of unpleasant bugs + you cant write script tags in the dom dynamically. It's a crippled platform.

推荐答案

或许你可以尝试安装在用户的计算机上的对象。有一个在线教程,似乎像它可以帮助:

Perhaps you could try attaching the object on the user's machine. There is a tutorial online that seems like it could help:

http://corlan.org/2008/09 / 02 /存储数据,本地的空气/

从网站实例:

//write an Object to a file
private function writeObject():void {
    var object:Object = new Object();//create an object to store
    object.value =  asObject.text; //set the text field value to the value property
    //create a file under the application storage folder
    var file:File = File.applicationStorageDirectory.resolvePath("myobject.file");
    if (file.exists)
        file.deleteFile();
    var fileStream:FileStream = new FileStream(); //create a file stream
    fileStream.open(file, FileMode.WRITE);// and open the file for write
    fileStream.writeObject(object);//write the object to the file
    fileStream.close();
}

这篇关于如何共享在Adobe AIR不同页面之间的JavaScript对象?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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