Load and reload external SWF in AIR for iOS

前端 未结 4 1743
灰色年华
灰色年华 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.

    0 讨论(0)
  • 2020-12-20 09:46

    You can't load a SWF file that contains any ActionScript ByteCode (ABC) then unload it and reload it on iOS. If you attempt to do this, the runtime throws error 3764.

    0 讨论(0)
  • 2020-12-20 09:49

    A good way to handle this would be to load the SWF files into separate movieclips the first time and then when needing to "load" them anytime after that, just show those movieclips that already have the SWF files loaded in them.

    0 讨论(0)
  • 2020-12-20 10:02

    If you can't load something a second time, perhaps it would be best to simply cache it and make a point of only loading it once?

    0 讨论(0)
提交回复
热议问题