在 AIR for iOS 中加载和重新加载外部 SWF [英] Load and reload external SWF in AIR for iOS

查看:26
本文介绍了在 AIR for iOS 中加载和重新加载外部 SWF的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现了一些关于如何加载一个或多个外部 SWF 文件的信息,这些文件与我的 AIR iOS 应用程序一起打包,实际工作代码是:

I found several info on how to load one or more external SWF files, packaged with my AIR iOS App, the actual working code is:

var myUrlRequest:URLRequest = new URLRequest(mySWF);
var myLoaderContext:LoaderContext = new LoaderContext(false, ApplicationDomain.currentDomain, null);
var loader: Loader = new Loader();
loader.load(myUrlRequest, myLoaderContext);
Object(root).MK.addChild(loader)

它适用于 Android 设备和 Windows PC,但在 iOS 上它只在第一次加载外部 SWF.在我的项目中,我有几个加载外部 SWF 的按钮,但每个按钮只在第一次起作用.

It works on Android devices and on Windows PC, but on iOS it loads the external SWFs only the first time. In my project I have several buttons that loads an external SWF, but each button works only the first time.

有什么想法吗?如果我无法重新加载 SWF,这似乎非常无用.

Any idea? It seems very unuseful if I can't reload an SWF.

推荐答案

即使第二次没有代码,我在加载 SWF 时也遇到问题.我找到的解决方案取决于代码是来自应用程序区域(与应用程序一起打包)还是外部加载(从 Web 或下载到缓存文件夹中).我写了一篇关于这里的扩展文章,如果你有兴趣:http://www.eqsim.com/blog/?p=400简而言之,这是我设置路径的代码:

I had problems loading SWF's even without code a second time. The solution I found depended on whether the code was from the application area (packaged with the app) or loaded externally (either from the web or downloaded into the caches folder). I wrote an extended post about here, if you're interested: http://www.eqsim.com/blog/?p=400 In a nutshell, here is my code for setting the path:

var moduleDirectoryPath = "/modules/";

if (externalContent == FROM_CACHE) {
   moduleDirectoryPath = File.cacheDirectory.url + moduleDirectoryPath;
} else if (externalContent == FROM_WEB) {
   moduleDirectoryPath = "http://our-online-content.com" + moduleDirectoryPath;
}

那么这里是我准备路径的代码,如果 SWF 来自应用程序区域或其他地方(缓存或网络):

then here is my code for preparing the path, if the SWF is from the app area or otherwise (cache or web):

if (loadFromApp) {
   path = moduleDirectoryPath + module_folder + "/" + module + "?nf="+getTimer();
} else {
   path = moduleDirectoryPath + module_folder + "/" + module;
}

最后,我的加载语句:

request = new URLRequest(path);
request.cacheResponse = false;
request.useCache = false;
_lc = new LoaderContext(false, ApplicationDomain.currentDomain, null);
moduleLoader.load(request, _lc);

现在我可以加载 SWF 并重新加载它们(更重要的是).当然,SWF 中没有字节码.

and now I can load SWF's and reload them (more importantly). Of course the SWF's do not have bytecode in them.

这篇关于在 AIR for iOS 中加载和重新加载外部 SWF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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