Load and reload external SWF in AIR for iOS

前端 未结 4 1832
灰色年华
灰色年华 2020-12-20 09:30

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 = n         


        
4条回答
  •  旧巷少年郎
    2020-12-20 09:36

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

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

    Finally, my loading statements:

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

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

提交回复
热议问题