상세 컨텐츠

본문 제목

[AS] air for iOS에서 swf reload는 지원하지 않는다. 관련

ADOBE/ ActionScript

by AlrepondTech 2020. 9. 22. 01:43

본문

반응형

 

 

 

 

=================================

=================================

=================================

 

 

 

 

 

 

출처: http://clack.tistory.com/391

air for iOS에서 swf reload는 지원하지 않는다.

iOS에서 loader로 로드했던 swf를 unload 한뒤 다시 로드 하려하면 아래와 같은 오류가 발생한다.

 

Reloading a SWF is not supported on this operating system

 

 

같은경로의 swf는 오류가 나는데 다른경로의 같은 swf는 된다고 한다.

더 자세한 내용은 아래 경로를 확인하자...

 

참조 : http://blogs.adobe.com/airodynamics/2012/11/09/packaging-and-loading-multiple-swfs-in-air-apps-on-ios/

 

 

출처 : http://ymson.tistory.com/entry/AIR-for-iOS%EC%9D%98-SWF-%ED%8C%8C%EC%9D%BC-%EB%A1%9C%EB%93%9C

 

 

=================================

=================================

=================================

 

 

 

출처: http://stackoverflow.com/questions/7904958/how-to-load-swf-file-from-bytearray

I'm working with the AIR application which loads the encrypted SWF from hard disc and decrypt this swf. After that I have byteArray of decrypted swf and I want to load it in Loader or SWFLoader.

private var file_byte:ByteArray;
private var myFileStream:FileStream;
private static var inputFile:File;
private var loader:Loader;

private function loadSWF(url:String):void
{
    inputFile = new File(url);
    myFileStream = new FileStream();
    myFileStream.addEventListener(Event.COMPLETE, completed);
    myFileStream.openAsync(inputFile, FileMode.READ);
    file_byte = new ByteArray();
}

private function completed(event:Event):void 
{
    myFileStream.readBytes(file_byte, 0, myFileStream.bytesAvailable);

    //Decrypting file 
    file_byte = decrypt(file_byte);

    // Prepare the loader context to avoid security error
    var loaderContext:LoaderContext = new LoaderContext();
    loaderContext.allowLoadBytesCodeExecution = true;
    loaderContext.allowCodeImport = true;

    // Load the SWF file    
    loader = new Loader();  
    loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onChildComplete); 
    loader.loadBytes(file_byte,loaderContext);
}

private function onChildComplete(e : Event) : void
{
    this.addChild(loader);
}

Security Error:

Error #3207: Application-sandbox content cannot access this feature.
at flash.system::Security$/allowDomain()
at rfx::MainTimeline_cbc00d6d7b3a063d505c336e0c8f32a1()[constructor.as:0]

byteArray is correct, I wrote him to the file in the disc and he worked in the Flash Player well. I read a lot of about sandbox, allowLoadBytesCodeExecution, external SWF files in AIR but I can't to solve this problem!

How to load swf file from byteArray?

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

I may be a bit late but I stumbled accross this while searching for my own problem. Try replacing your constructor call with this instead.

var loaderContext:LoaderContext = new LoaderContext(false, ApplicationDomain.currentDomain);

 

 

=================================

=================================

=================================

 

 

 

 

출처: http://stackoverflow.com/questions/18376329/how-to-reload-swf-reload-class-definition-in-a-running-application

i work with FlashPro and FlashBuilder. I have an application in AIR, which reads resources from SWF created in FlashPro.

The problem is that if I change something in the FlashPro and reload swf'a nothing has changed. I get the same symbols, and functions return the same data.

If I run the application again and load swf only then I can see the changes.

It seems that if AVM2 (FlashPlayer) load a class it is confident that this class does not change its content.

I use class Loader to load swf.

Does anyone know how to reload swf

My function:

protected function loadResourceFile() :void
{
    if (_resourcesFile != null) {
        _resourcesFile.unload();
        _resourcesFile = null;      
    }

    var ba :ByteArray = new ByteArray();
    var fs :FileStream = new FileStream();

    var srcFile : File = File.applicationDirectory.resolvePath(edResourcesSWF.text);
    try {
        fs.open(srcFile, FileMode.READ);  // Otwarcie synchroniczne, można też asynchronicznie - openAsync()
        fs.readBytes(ba);
        fs.close();
    } catch (e :Error) {
        Alert.show('Błąd odczytu z pliku: ' + srcFile.nativePath + '\n\n' + e.message, 'Błąd');
        return;
    }

    _resourcesFile = new Loader();
    _resourcesFile.contentLoaderInfo.addEventListener(Event.COMPLETE, loadResourceFile_loaded);
    _resourcesFile.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, loadResourceFile_ioErrorHandler);
    try {
        var context :LoaderContext = new LoaderContext(false, ApplicationDomain.currentDomain);
        context.allowCodeImport = true;
        context.allowLoadBytesCodeExecution = true;

        _resourcesFile.loadBytes(ba, context);  //  <--- Load SWF
    }
    catch (e :Error) {
        Alert.show('Nie można wczytać pliku zasobów: "' + edResourcesSWF.text + '"\n\n' + e.message, 'Błąd');
    }
}

 

1 Answer

There are a couple of things going on here... the first is that when you load the same Class from different swfs (which in essence is what you are doing), Flash assumes that the first definition it got is the correct one. You can get around this with things like loader contexts, but I suspect that your loading swf is directly touching the loaded Classes, so this probably won't work for you. I see you're choosing to load everything in the main context, so it's definitely not going to work for you until you change that.
Instead of directly touching the Classes, instead program to Interfaces (Abstract or Base Classes would work as well) and provide an API for your main swf to request the local implementation of the Interface from the loaded swf. This would allow you to isolate the different Class implementations inside the Application context.
A second issue is probably that the swf is being cached by the browser. You can get around this by appending a parameter to the url: loader.load('http//:www.yourDomain.com/swfs/yourfile.swf?nocache=' + getTimer());

 

 

 

=================================

=================================

=================================

 

 

출처: http://ymson.tistory.com/entry/AIR-for-iOS%EC%9D%98-SWF-%ED%8C%8C%EC%9D%BC-%EB%A1%9C%EB%93%9C

AIR for iOS의 SWF 파일 로드

iOS 장치에서는 런타임에 코드를 로드하고 컴파일하는 데 제약이 있습니다. 이 제약 때문에 외부 SWF 파일을 응용 프로그램에 로드하는 작업이 약간 다를 수밖에 없습니다.

  • ActionScript 코드가 포함된 모든 SWF 파일은 응용 프로그램 패키지에 포함되어야 합니다. 코드가 포함된 SWF는 네트워크 등의 외부 소스로부터 로드할 수 없습니다. 응용 프로그램을 패키지화할 때 응용 프로그램 패키지에 포함된 모든 SWF 파일의 ActionScript 코드가 iOS 장치용 기본 코드로 컴파일됩니다.
  • SWF 파일을 로드하고 언로드했다가 다시 로드할 수는 없습니다. 이렇게 하려고 하면 오류가 발생합니다.
  • 메모리에 로드한 다음 언로드하는 동작은 데스크톱 플랫폼에서와 동일합니다. SWF 파일을 로드했다가 언로드하면 SWF에 포함된 모든 시각적 에셋이 메모리에서 언로드됩니다. 하지만 로드된 SWF의 ActionScript 클래스에 대한 클래스 참조는 메모리에 그대로 유지되며 ActionScript 코드에서 이를 액세스할 수 있습니다.
  • 로드되는 모든 SWF는 기본 SWF 파일과 동일한 응용 프로그램 도메인에 로드되어야 합니다. 이는 기본 동작으로 수행되지 않습니다. 따라서 로드하는 각 SWF에 대해 기본 응용 프로그램 도메인을 지정하는 LoaderContext 객체를 생성하고 이 LoaderContext 객체를 Loader.load() 메서드 호출에 전달해야 합니다. SWF를 기본 SWF 응용 프로그램 도메인이 아닌 응용 프로그램 도메인에 로드하려고 하면 오류가 발생합니다. 이는 로드 대상 SWF에 시각적 에셋만 있고 ActionScript 코드가 없는 경우에도 마찬가지입니다.
  • 다음 예제에서는 SWF를 응용 프로그램 패키지에서 기본 SWF 응용 프로그램 도메인으로 로드할 때 사용하는 코드를 보여 줍니다.
var loader:Loader = new Loader(); 
var url:URLRequest = new URLRequest("swfs/SecondarySwf.swf"); 
var loaderContext:LoaderContext = new LoaderContext(false, ApplicationDomain.currentDomain, null); 
loader.load(url, loaderContext);

에셋만 있고 코드가 없는 SWF 파일은 응용 프로그램 패키지 또는 네트워크에서 로드할 수 있습니다. 어느 쪽에서 로드하든 SWF 파일은 기본 응용 프로그램 도메인으로 로드되어야 합니다.

AIR 3.6 이전의 AIR 버전에서는 모든 코드가 컴파일 과정에서 기본 응용 프로그램 SWF 이외의 모든 SWF에서 제거됩니다. 시각적 에셋만 있는 SWF 파일은 런타임 시 응용 프로그램 패키지에 포함하고 로드할 수 있지만 코드는 그렇지 않습니다. ActionScript 코드가 포함된 SWF를 로드하려 하면 오류가 발생합니다. 이 오류로 인해 응용 프로그램에 "컴파일되지 않은 ActionScript"라는 오류 대화 상자가 나타납니다.

참고 사항

iOS의 AIR 응용 프로그램에서의 여러 SWF 패키지화 및 로드

 

 

 

 

=================================

=================================

=================================

 

 

출처: http://blogs.adobe.com/airodynamics/2012/11/09/packaging-and-loading-multiple-swfs-in-air-apps-on-ios/

In AIR SDK 3.6 for iOS, there is a new feature that allows application developers to be able to package and load secondary SWFs that contain ActionScript byte code (or ABC) in their apps. Presently, due to certain restrictions on iOS, AIR on iOS requires that all the ActionScript code of an application be present in the main SWF or the root SWF. With this feature, an application developer can have ActionScript code in local secondary SWFs and package them along with the main SWF.

 

A bit of background

AIR apps on iOS can be compiled either in AOT (ahead of time) mode or Interpreter mode. To know more about these modes, please refer to an earlier post on this blog: http://blogs.adobe.com/airodynamics/2012/07/04/aot-or-interpreter/

The AIR Developer Tool or ADT has targets that lets you package apps either for the AOT mode or Interpreter mode. The targets for packaging in AOT mode are ipa-app-store, ipa-ad-hoc, ipa-test and ipa-debug. The targets for packaging apps in interpreter mode are ipa-debug-interpreter, ipa-test-interpreter, ipa-debug-interpreter-simulator and ipa-test-interpreter-simulator. In the interpreter mode, as the SWF is interpreted and not translated to native machine code, hence it runs slower than when in AOT mode. All developers are advised that whenever they publish their apps on the AppStore, they should make sure that they are compiled in AOT mode. To read more about the ADT command and the iOS package targets please refer to: http://help.adobe.com/en_US/air/build/WS901d38e593cd1bac1e63e3d128cdca935b-8000.html

This feature affects only the AOT mode targets and the behavior of the interpreter mode targets is unchanged.

Until now, AIR required that when packaging in AOT mode, all the ActionScript code of an AIR iOS app should be present inside the main SWF. Any SWF other than the main SWF, that is provided at the time of packaging, is added to the final application package (IPA) as a resource. Any attempt to load a SWF (local or remote) dynamically that contains ActionScript byte code (or ABC) using either Loader.load() or Loader.loadBytes,  resulted in an “Uncompiled ActionScript” error. A screenshot of the error dialog is below:

 

 

After the user dismisses the error dialog, the behavior of the application is “undefined”. Developers should never ship or publish an app in which the user may see such an error dialog.

Please note that if the SWF that is being loaded dynamically does not contain any ABC and contains only assets like bitmaps or audio, the SWF will be loaded successfully (even with AIR 3.4 and before). In fact, few developers have used this technique, to host asset-only SWFs on web servers and these are fetched only when needed. By downloading asset-SWFs on demand at run-time, developers have been able to reduce the size of their applications.

What has changed ?

In addition to the main SWF, the application developer can now provide a secondary SWF that contains ActionScript bytecode at the time of packaging and then load such a SWF dynamically using the functions provided by Loader. However, while dynamically loading a secondary SWF inside the main SWF, one needs to provide the application domain in which the secondary SWF should be loaded. The AOT mode in AIR on iOS does not support multiple application domains.

Below is a code snippet for loading a secondary SWF that is packaged with the application.

var _urlRequest:URLRequest = new URLRequest(“mySecondarySwf.swf”);
var _loader:Loader = new Loader();
_loader.load(_urlRequest);

 

When the Loader.load() method does not specify a LoaderContext object, then by default, the SWF is loaded in an application domain that is a child of the loading SWF’s application domain. Multiple application domains are not supported in AIR on iOS, and hence the above code will not work on iOS and will result in the following error:

Error 3747: Multiple application domains are not supported on the operating system.

To overcome this error, the above code needs to provide ApplicationDomain.currentDomain as the application domain in the LoaderContext object. So the modified code is:

var _urlRequest:URLRequest = new URLRequest(“mySecondarySwf.swf”);
var _loader:Loader = new Loader();
var _lc:LoaderContext = new LoaderContext(false, ApplicationDomain.currentDomain, null);
_loader.load(_urlRequest, _lc);

 

Loader.loadBytes

There is no change in the behavior of Loader.loadBytes() except for: In AOT mode, if the user attempts to load a SWF using Loader.loadBytes() and if the SWF version of the root SWF is greater than or equal to 19 (i.e. for the given build) then, the user needs to provide an application domain as part of the loader context which should be same as the root SWF’s application domain.

Loader.unload() & Loader.unloadAndStop()

The behavior of Loader.unload() and Loader.unloadAndStop() on iOS is below. When either of these functions is called the following will happen:

  1. The contentLoaderInfo property of the Loader object will become null
  2. Any assets that are loaded with the secondary SWF will be unloaded.
  3. Any references to AS classes in the loaded SWF remain in memory, and new objects of those AS classes can be created. This is different from the behavior on other platforms.

SWF Reloading

In AIR apps on iOS running in AOT mode there is a problem when a SWF is reloaded. Therefore reloading a SWF will not be allowed for AIR apps for iOS in AOT mode and attempting to do so will result in following error:

Error 3764: Reloading a SWF is not supported on this operating system

Note:If a SWF is accessed using different URLs like different paths referring to the same SWF, or using app:// and app-storage:// URI schemes to access the same SWF, then the two SWFs would be considered different and the SWF will be re-loaded. However, the behavior in such cases would be undefined.

Note: Reloading of pure asset SWFs will work with AIR 3.7 builds which can be downloaded from here

A bit about what happens behind the scenes …

The ABC code from the main SWF and all the secondary SWFs is extracted and placed in the main executable. The non-ABC parts of a SWF or assets in a SWF are kept inside the IPA (as assets). They are drawn in memory when explicitly asked using the Loader.load() call.

What will still not work?

1.Dynamically loading a ‘remote‘ SWF, that contains ActionScript code will continue to NOT work.
2.Embedding SWFs(having ABC code) using [Embed] tag will NOT work on iOS.

Where can I get the build?

The build with this feature can be accessed here

To summarize:

For locally packaged secondary SWFs:

  AOT (Ahead of Time) Mode Interpreter Mode
Local secondary SWF with ABC Earlier loading such a SWF gave the uncompiled AS Error.With this feature, this will work Works (unchanged)
Local secondary SWF w/o ABC Works (minor change required)* Works (unchanged)

For remote SWFs:

AOT (Ahead of  Time) Mode Interpreter Mode
Remote SWF with ABC Prohibited by Apple Prohibited by Apple
Remote SWF without ABC Works (minor change required)* Works (unchanged)

*The minor change is that when loading the SWF, the application domain should be the same as that of the main SWF i.e. ApplicationDomain.currentDomain.

Some FAQs

  • What is the loading order of ActionScript code among root SWF, secondary SWFs and ANEs?
    • The loading order is ANE, followed by main SWF, followed by secondary SWFs. This implies that if there is a class with the same name that is defined in the main SWF as well as the secondary SWF, then the class definition of the main SWF will be used.
  • Will I be able to load remote SWFs that don’t contain any ActionScript code?
    • As evident from the above table, the answer to this is YES.
  • Will I be able to use Workers API on iOS?
    • ActionScript workers is not supported on iOS. Worker.isSupported on Mobile (both iOS and Android) would continue to return false.

Points To Note:

  • Conflicting symbols (classes and global functions) in all the packaged swfs should be avoided, they might result into undesired behaviour.

 

51 Responses to Packaging and loading multiple SWFs in AIR apps on iOS

  1. Rob M says:Will the exact same code work on Android as well or will we need to do something different?
    • divij says:Yes the same code that works for iOS will work on Android as well. This functionality of allowing the loading of ActionScript bytecode from secondary SWFs is already present for AIR apps on Android.
    • November 12, 2012 at 11:27 pm
  2. November 9, 2012 at 9:12 pm
  3. Pingback: tapzat » Packaging and loading multiple SWFs in AIR apps on iOS « AIR-o …
  4. Alan Lammers says:Hi Divij,Thank you very much in advance.
    • divij says:The feature is available in 3.5.290 as well as in 3.5.460. It was disabled in a later build which is 3.5.520. If you face any issues with this build then do let us know.
    • November 12, 2012 at 11:24 pm
  5. Regards,
    Alan Lammers.
  6. We are working in a App that needs to load a secondary SWF with code, so this functionality is very importatn for us.
    The build you linked here is 3.5.460, but i think the correct build is 3.5.290.
    Could you please post the link to this build or send it to us by mail?
  7. November 12, 2012 at 9:03 pm
  8. Ed Guertin says:Very interesting to read about this as I have made a system to get around the no ABC code in external swfs problem. Maybe all my hard work is redundant if now AIR for ios can compile as3 code from a secondary swf! I am very confused though… in this article you said near the beginning:Then towards the end you said:Can the new AIR load external swfs with ABC or not?
    • divij says:The second statement should read ‘Dynamically loading a remote SWF, that contains ActionScript code will continue to NOT work.’ Missed the crucial “remote”. Thanks for your comment.
    • November 14, 2012 at 12:21 pm
    • Jeff Ward says:Ed, it works for local SWFs – this means they need to be packaged in the app .ipa file (and hence ABC code is processed by the AOT compiler.) SWFs with code can’t be loaded from a server (remote, unprocessed).
    • February 18, 2013 at 11:48 pm
  9. Thanks very much if you have time to answer this.
  10. ‘Dynamically loading a SWF, that contains ActionScript code will continue to NOT work.’
  11. ‘Until now…. Any attempt to load a SWF (local or remote) dynamically that contains ActionScript byte code (or ABC) using either Loader.load() or Loader.loadBytes, resulted in an “Uncompiled ActionScript” error’
  12. November 13, 2012 at 3:23 pm
  13. Clint Modien says:Does this mean we can load one and only one external swf with abc bytecode in it?
    • divij says:No, you should be able to load any number of external SWFs with abc. You just need to provide all such external SWFs at the time of packaging (i.e. when running the ADT command).
    • November 14, 2012 at 12:16 pm
  14. November 13, 2012 at 8:12 pm
  15. James Hunt says:Do instance names count as ABC or just actual Classes’s/AS Code?
    • divij says:If you have any AS code then your SWF contains ActionScript bytecode. If you only have asset files like JPEGS or mp3s in your SWF files, even then the SWF will contain ActionScript bytecode if you have exported AS Linkages.
      If you unload and then reload the SWF, then the behavior would be random. In some cases it may even possibly crash your application. We are working on this, and it will be modified, when this feature is released in a future AIR version.
    • November 18, 2012 at 11:52 pm
  16. Also if you unload and then reload the same SWF with just instance names would this result in the “random behaviour” you talk about?
  17. November 15, 2012 at 8:07 pm
  18. Adam says:I am currently using one of the 3.5 beta sdk, and am successfully loading swfs with exported linkage ids and creating new instances of them based on those ids. Are you saying that the 3.5 final release I will not be able to do this?
    • divij says:If you have secondary SWFs that have exported AS linkages, and if you try load such a SWF, and you compile your app in AOT mode (for iOS), then you would get an “Uncompiled AS warning” error if you try with AIR3.5 final release or any of the previous AIR (final) releases. The same would not happen with the previous AIR 3.5 beta releases.
    • November 18, 2012 at 11:45 pm
  19. November 17, 2012 at 5:03 am
  20. jian says:Could you explain more about the below statements, especially the first one?
    * Local secondary SWF with ABC + Interpreter Mode: Works (unchanged)
    * Remote SWF with ABC + Interpreter Mode: Prohibited by Apple
  21. November 19, 2012 at 7:37 am
  22. John says:Is a Secondary SWF that contains frame labels and instance names considered a “Secondary SWF with ABC?”
  23. November 21, 2012 at 12:44 am
  24. Kelsey says:Hi Divij,Why has this feature been disabled in the final release? Will it be brought back in future releases?
  25. “The feature is available in 3.5.290 as well as in 3.5.460. It was disabled in a later build which is 3.5.520″
  26. November 23, 2012 at 12:27 am
  27. Ken Patel says:Is [Embed] supported or unsupported in this new feature?Eager to hear back. Thank you very much!
    • Nimisha says:Thanks Ken for letting us know about this issue, we’re investigating it.
    • December 6, 2012 at 5:40 pm
    • Jeff Ward says:Ken, embedding is unsupported. It won’t work because it stores asset bytes directly which bypasses the AOT compilation for the embedded SWF. Use a Loader instead as described above.
    • February 18, 2013 at 11:45 pm
  28. I am using the [Embed] tag to embed my secondary swfs. I installed the linked build of the AIR SDK, set my application.xml to reference 3.5, and added the -swf-version=18 option, but am still getting the ‘Uncompiled Actionscript’ warning dialog.
  29. December 3, 2012 at 4:55 am
  30. Miguel Santirso says:Hello, I was very happy to read about this until I saw this:If I understand correctly, that makes this new feature completely useless :S The whole point of loading multiple swfs is being able to load resources “on demand” and unloading them when you don’t need them.
  31. The most obvious use case is a game in which the assets for each level are packaged into one .swf. Then you would load the assets when the player enters a level, unload them when he changes to a different level. But, obviously, I would need to reload the .swf of the first level if the player decides to play it again in the same session.
  32. “reloading a SWF will not be allowed for AIR apps for iOS in AOT mode”
  33. December 14, 2012 at 2:28 pm
  34. Gaius says:Hi,
    Can you confirm; I need to import SWF display assets, there is ABC in them (not from me, and I don’t use or need it). I had assumed that it was just stripped out and not used during release, but you are saying that there is an error dialog _even_ for release?
    Do you know if there is an option to expressly ignore and prohibit ABC so as to treat the SWF purely a an asset library?
    G
  35. December 14, 2012 at 3:54 pm
  36. Jason says:I see that Beta 3.6 is out. Is this feature working and available in the beta version? Also does Android have any restrictions on loading remote swfs with actionscripting?
    • divij says:Yes, this feature is available in the 3.6 Beta. Please set swf-version as 19 to use this feature.
      There are no restrictions when loading remote SWFs on Android.
    • January 9, 2013 at 12:57 pm
  37. January 9, 2013 at 1:58 am
  38. Yoyo says:Dear Divij,
    I try to embed SWF file with ActionScript to IOS application using Adobe Air. I use adobe air 3.6 and flash builder to load the secondary swf (existing SWF as an asset). On compiling I have added “-swf-version=19″, but still no success. The swf is loaded but not the ActionScript.
    This is my code :// Prepare the loader context to avoid security error
    var loaderContext:LoaderContext = new LoaderContext(false,ApplicationDomain.currentDomain,null);
    loaderContext.allowLoadBytesCodeExecution = true;
    loaderContext.allowCodeImport = true;
    • divij says:Are you using the “Embed” tag to package the secondary SWF in your main SWF? Embedding a SWF (with ABC code) will not work.
    • However, if a secondary SWF contains ActionScript code, package it via the ADT command (without specifying the “Embed” tag). Also, do make sure to use namespace=3.6 and -swf-version=19.
    • February 28, 2013 at 7:25 pm
  39. // Load the SWF file
    loader = new Loader();
    loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onChildComplete);
    loader.load(urlRequest,loaderContext);
  40. var urlRequest:URLRequest = new URLRequest(“assets/secondFile.swf”);
  41. January 19, 2013 at 7:26 am
  42. talata_bao says:thanks, I have done but still a little buggy when I removeChild swf file and try to load the file is not.please help me
  43. January 19, 2013 at 12:09 pm
  44. Julie says:It’s great application! If everyone is interested in, here are some adobe.com coupons code: http://sslash.com .
  45. January 21, 2013 at 3:59 pm
  46. pqbao1987 says:Hi divij,var _urlRequest:URLRequest = new URLRequest(“mySecondarySwf.swf”);
    _loader= new Loader();
    var _lc:LoaderContext = new LoaderContext(false, ApplicationDomain.currentDomain, null);
    _loader.load(_urlRequest, _lc);
    loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoadCompelte);
    function onLoadCompelte(e:Event):void{
    addChild(loader);
    }
    }
    btn.addEventListener(MouseEvent.CLICK,onCheck);
    function onCheck(e:MouseEvent):void
    {
    if(loader) removeChild(loader)
    }
  47. when I removeChild and try reload “mySecondarySwf.swf” file is not,
  48. i’m using method:
    var _loader:Loader
    btn_load.addEventListener(MouseEvent.CLICK,onLoadSwf);
    function onLoadSwf(e:MouseEvent):void{
  49. January 22, 2013 at 10:45 am
  50. Andrea says:Hi,Thanks
  51. i have install AIR 3.6Beta SDK to Adobe Flash Pro CS6 IDE and compile my iOS application that load external SWF but every time i finished to create .ipa i receive a warning: as code into SWF loaded externaly will not execute into iOS devices.
    What can i do to load externaly SWF? I don’t known how set swf-version as 19.
  52. January 31, 2013 at 6:04 pm
  53. Lorenzo says:What happens if I load a bunch of graphic SWF (no code) and then I unload them to save some space? How can I reload them consequently if I need to show that graphic again?
  54. February 7, 2013 at 3:29 am
  55. Luiz Fernando says:Is this feature avaiable on 3.5.0.600?
  56. February 7, 2013 at 7:26 pm
  57. Joshua Kernich says:Does this support the loading of nested swfs? i.e. Can a loaded swf load another swf?
    I have been able to get my main application to load 2 child swfs individually but when I have one of the child swfs loading the other, it doesn’t work. I get one progress event from the loader that tells me 0 bytes have been loaded (total bytes also traces correctly). Then the app appears to completely freeze. I am also using the same context object created by the parent swf with the same Application domain.
    • Nimisha says:Hi Joshua,
    • Nested SWFs are supported and should work. Can you send a sample app (swfs, app-xml and source code)with which you’re facing this issue @nimisha1@adobe.com.
    • February 28, 2013 at 8:23 pm
  58. February 20, 2013 at 10:10 am
  59. Pingback: (转)Adobe AIR读取本地外部SWF文件的功能概览 | 湖心小筑
  60. Alex says:I am using a system whereby any sounds that need to loop are kept in external swfs that I load on arriving at a screen and then unload on exiting the screen. I’ve just discovered that this leads to the problem of not being able to re-load the same swf if I later try to return to the screen. I get the error ’3764 – Reloading a SWF is not supported on this operating system.’
    Is there really no way around this? How does it know that I’ve loaded that swf before?
    • nimisha says:Hi Alex,
      1.How does it know that I’ve loaded that swf before?
      Ans: Runtime for iOS has been implemented like this where reloading of a SWF is prohibited.
      2.Is there really no way around this?
      The best way to deal with reload problem is that to not unload a SWF from your app instead just use/un-use it. I don’t know how you’re implementing things in you app’s SWFs but if the SWF is visible then then just make it invisible at the time of un-usage. To use this workaround you need to have different loaders for different SWFs.
      • Alex says:Hi nimisha, thanks for your reply. Regarding your suggestion of not unloading the swfs, the problem with this is that i would then quickly run out of memory on mobile devices. I wanted to use this functionality to allow me to load swfs that just contain audio (music) that I wish to loop seamlessly. If I kept each swf (and hence each music loop) in memory, uncompressed, it would use up all available memory.
      • March 21, 2013 at 4:13 pm
    • March 1, 2013 at 12:26 pm
  61. February 25, 2013 at 9:52 pm
  62. tom says:I have problem too. CAN SOMEONE HELP PLEASE!
    I want to load and reload swfs. It’s not working with air3.6. When I test on PC it’s fine – work well I reload swf meny times. On iPad works only one. I can not reload swf. I put simple code. Can someone help me to fix it?var myLoaderSWF:Loader = new Loader();
    var mc:MovieClip;function initSkyview(e:MouseEvent):void
    {
    btnSkyview.visible = false;
    btnGround.visible = true;
    initSlide(“slide_skyview”);
    }function initSlide(_names):void
    {
    unloadSWF2();
    var _loadURL:String = “source/” + _names + “.swf”;
    myLoaderSWF = new Loader();
    //myLoaderSWF.contentLoaderInfo.addEventListener(Event.COMPLETE, loadSWFComplete);
    var url:URLRequest = new URLRequest(_loadURL);
    var loaderContext:LoaderContext = new LoaderContext(false,ApplicationDomain.currentDomain,null);//loadSWF is movie clip created on stage puted on layer
    loadSWF.addChild(myLoaderSWF);
    }
    function unloadSWF2():void
    {
    var mcSWF2:MovieClip = myLoaderSWF.content as MovieClip;
  63. if (myLoaderSWF.content && mcSWF2.totalFrames > 1 && mcSWF2.totalFrames)
    {
    myLoaderSWF.unload();
    }
    }
  64. myLoaderSWF.load(url, loaderContext);
  65. function initGround(e:MouseEvent):void
    {
    btnSkyview.visible = true;
    btnGround.visible = false;
    initSlide(“state_sampt”);
    }
  66. btnSkyview.addEventListener(MouseEvent.MOUSE_DOWN, initSkyview);
    btnGround.addEventListener(MouseEvent.MOUSE_DOWN, initGround);
  67. stop();
    import flash.events.MouseEvent;
  68. March 1, 2013 at 6:48 pm
  69. Pingback: Packaging and loading multiple SWFs in AIR apps on iOS « AIR-o … | S60Aplicativos
  70. Kelsey says:In my application, I have a game that has many different themes. All themes share an almost identical codebase (including package and class definitions), but the graphics are completely different. In the Android version, I was able to load and unload the swfs successfully by loading them into a child domain of the Application.currentDomain. But for iOS, since they must be loaded into the ApplicationDomain.currentDomain, the result is that the first swf works fine, but thereafter, many of the graphics from the inital swf are being displayed instead of graphics from the new swf.
    Is there a solution to properly overriding the class definitions created from the inital swf? Or will I have to go into each swf and rename every class definition so they don’t conflict?
  71. March 20, 2013 at 1:38 am
  72. Kev says:Hi,I tested each swf one by one, and they work fine, if they are the only swf in the bin folder, has anyone got any advice regarding this?
    • Kev says:Also, I’ve tried the external loading with air 3.7
      • Abhinav says:Hi Kev
        • Kev says:Hi AbhinavBut the first problem still exists, the swf version is 20, the packaging target is ad-hoc. On a side note, loading swfs seem to have a weaker performance than just including it as an internal swc library.regards,
          Kevin
        • The same problem persists, even when compiling them as local swfs. It seems as though only the first swf ( alphabetically) can be used, and no the others. Using any other than the first one will result in the game not loading anything.
        • Please ignore the second comment I posted, it seems to work fine when transfered to the iphone.
        • March 23, 2013 at 11:33 pm
      • Could you please confirm the following 2 things :
        1. SWF version of the Root SWF of your application ?
        2. The packaging target in which the IPA has been packaged ?
      • March 22, 2013 at 3:38 pm
    • The externally stripped swfs seem to generate the error 1042: not an abc file.
      Any clues on this too?
    • March 22, 2013 at 3:15 pm
  73. I have multiple secondary swfs that requires loading, however, flashdevelop seems to only package only the first swf, hence the application will not run when other swfs are loaded and used.
  74. March 22, 2013 at 9:27 am
  75. Kev says:Just to add a little on the situation, using the loader to load the other SWFs results in the debugger prompting an internal debugger exception.
  76. March 25, 2013 at 12:05 pm
  77. Nathan says:Hello,I’m using AIR 3.7 and I’m trying to load a local file. The file is a Captivate swf that shows the preloader when loaded, but does not load the rest of the swf.Thanks.
    Nathan
  78. Any thoughts?
  79. I can get this to work when testing through the adl in Flash, but it does not work on my iPad..
  80. April 19, 2013 at 7:52 pm
  81. Pingback: Flash cs 5.5 embed - Flashforum
  82. biscito says:use loadermax and i’ll works fine,
  83. _assets = new LoaderMax({name:”mainQueue”, onProgress:progressHandler, onComplete:completeHandler, onError:errorHandler});
    _assets.append(new SWFLoader(“LevelA1.swf”, {name:”levelA1″, context:new LoaderContext(false, ApplicationDomain.currentDomain, null)}));
    _assets.append(new SWFLoader(“LevelA2.swf”, {name:”levelA2″, context:new LoaderContext(false, ApplicationDomain.currentDomain, null)}));
  84. May 20, 2013 at 6:59 pm
  85. cyberprodigy says:Best news ever 
  86. August 12, 2013 at 9:58 pm
  87.  

 

 

 

=================================

=================================

=================================

 

 

출처: http://forums.adobe.com/message/5823512

Why reloading pure asset SWF with AIR sdk 3.6+ doesn't work?

Oct 24, 2013 10:43 AM

Tags: #flash #ios #3.6 #3.7 #3.8 #doabc2

Hi,

 

I have a game targeting iOS using AIR sdk that needs to load many swf assets from the disk (packaged with the game). When using AIR sdk 3.5, everything runs just fine. When upgrading the sdk to 3.6 or later (-swf-version=19, 20, 21), we ran into the following problems:

 

1) The packaging time (making the ipa file for iOS) passes from 15 minutes to 40+ minutes.

2) The game can't load any swf twice (ie. reload a swf).

 

The first problem is not a big deal. We only have to wait a little bit more. Our guess is that is has to do with new feature introduced by the sdk 3.6, which will go through all packaged secondary swfs and remove the code from it, and since we have lot of swf assets, it takes more time.

 

The second problem is way more serious, as I have to be able to reload assets according to player's action. Since we have a ton of assets, I can't keep them all in the memory as we could quickly run out of memory.

 

I know that there's a documented limitation of sdk 3.6 which states:

 

In AIR apps on iOS running in AOT mode there is a problem when a SWF is reloaded. Therefore reloading a SWF will not be allowed for AIR apps for iOS in AOT mode and attempting to do so will result in following error:

 

Error 3764: Reloading a SWF is not supported on this operating system

 

It also says that "Reloading of pure asset SWFs will work with AIR 3.7". However, that's not true, since all my assets are pure asset SWF without any code inside. It won't work, even with AIR 3.8.

 

While searching on the internet, I came across a forum post that says that the only way to know if a swf is a pure asset swf, is by using swfdump.exe, and searching for the DoABC2 tag. I did it, and effectively, DoABC2 tag was there, but empty.

 

So my first observation is that:

 

- Pure asset SWF file containing empty DoABC2 tag can be reloaded using AIR SDK 3.5

- Pure asset SWF file containing empty DoABC2 tag can't be reloaded using AIR SDK 3.6+

 

It seems to me that AIR SDK 3.6+ doesn't care if the tag is empty or not. If it is there, then it's not ok.

 

Then I wanted to know why my SWFs have this empty tag. After lot of tests, it turns out that it is because I am using jsfl to automate the export of assets from a FLA file. And there comes my second observation:

 

- When exporting a swf without code from Flash IDE (Ctrl+Alt+Shift+S), there's no empty DoABC2 tag.

- When exporting a swf from the Flash IDE's library (right click on the library Movieclip -> Export Flash movie...), empty DoABC2 tag is automatically inserted.

 

Unfortunately, my jsfl script uses thee same Library export functionality, and it produces the same "contaminated" swf. Why doesn't it produce the same SWF from both ways of export? I have no idea.

 

In the perfect world, the AIR SDK would not only look for the DoABC2 tag, but it should check whether if there's code inside. Also, Flash should use the same export process disregarding if it is being called from the IDE or the Library, and not inserting empty DoABC2 tag when there's no code.

 

As for now, I can't find any workaround to solve my problem. That means that I'm stuck with swf-version=18, and I can't benefit from all the cool features such as rectangle textures, new Context3DTextureFormat etc.

 

If anyone has a solution, or simply pointing out what I'm doing wrong here, please share it.

 

Thanks for reading.

 

Iojeirg

Translate

392 Views   3 Replies   Latest reply: makc3d, Nov 7, 2013 8:42 AM

Was this helpful? Yes   No

 

Replies



  • Report

    Was this helpful? Yes   No
  • Translate
  • I do not have ready code to do so, but it's very easy to write  E.g. take a look at this code that uses as3swf to add the tag - it is really easy to modify it to remove doabc tag.
  • well then the obvious solution would be to remove the tag, no? if the tag is not actually used in the swf in any way, this should cause zero problems.
  • > It seems to me that AIR SDK 3.6+ doesn't care if the tag is empty or not. If it is there, then it's not ok.
  • Nov 7, 2013 8:27 AM   in reply to iojeirg
  • 1.makc3d,


  • Report



    Was this helpful? Yes   No
  • Translate
  • Your solution is a nice workaround, and I will certainly try that out. But as I said, it will not fix the original bug, it will only patch it later on in the process.
  • Also, AIR should check for actual code in this tag instead of relying only on the tag itself.
  • I would not say that the abvious solution is to remove the tag. I think it should not be put there in the first place if there's no code at all. Moreover, this only happens when exporting a MC from the Library, and it works just fine when exporting normally (publish). It seems more like a bug than an expected behaviour.
  • Thanks for the response. After all that time I started losing hope. 
  • Hi makc3d,
  • Nov 7, 2013 8:40 AM   in reply to makc3d
  • 2.iojeirg,


  • ReportWas this helpful? Yes   No
  • That is true, however adobe is slow. If you want it to work today, it's your job to fix it.
  • Nov 7, 2013 8:42 AM   in reply to iojeirg
  • 3.makc3d,

 

 

 

=================================

=================================

=================================

 

 

출처: http://forums.adobe.com/message/5911006

iOS app using Air 3.9 - how can we reload a swf that was previously loaded?

Dec 8, 2013 1:23 AM

We are developing an iOS app using the air 3.9 sdk. Our application is such that we have 2 SWFs packaged inside the ipa file i.e.the main.swf and an experience.swf.
The main.swf is loaded initially using application.xml. A button-click within the main.swf loads the experience.swf (which is located within the bin folder in the ipa, NOT remotely downloaded). This experience.swf contains assets and code.

When we create an ad-hoc build, experience.swf loads perfectly the first time, but if the user returns to the main.swf and then tries loading the experience.swf again, it doesn't load. Just the default stage color is visible. (This problem only occurs on the ad-hoc build. The debug build has no such issues)

 

To load this experience.swf we are using the flash.display.loader with loaderContext set as the ApplicationDomain.currentDomain. 

mcExperience = new MovieClip();
var url:URLRequest = new URLRequest("ChristmasExperience.swf");
var loaderContext:LoaderContext = new LoaderContext(false, ApplicationDomain.currentDomain, null);

loader.load(url, loaderContext);
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, CompleteHandler);

addChild(mcExperience);
private function CompleteHandler(e:Event):void
{
trace("I HAVE LOADED .... SWF loaded... , waiting for the constructor call back..." + e.target.loader.content);
//mcExperience.addChild(loader);
mcExperience.addChild(MovieClip(e.target.loader.content));
//TODO : Set the Session ID Here
m_experienceBase.SetSessionID(int(m_ExperienceSessionID));
m_experienceBase.SetLocalPlayer(m_localPlayer);
//(loader.content as MovieClip).soundTransform = new SoundTransform(0);
//addChild(loader);
//setChildIndex(m_tfConsoleMsgDisplay, numChildren - 1);
}

When the experience is unloaded, we remove the holder MovieClip of the experience.swf and unload the flash.display.loader. This still does not re-load the previously loaded experience.swf.

if (mcExperience)
{
mcExperience.removeChildren();
removeChild(mcExperience);
mcExperience = null;
}

We are using swf-version=22 for both main and experience swf.

 

This is quite a big problem for us and we've gone through a bunch of posts, to help understand this issue better (a few examples below):

http://stackoverflow.com/questions/20039377/adobe-air-ios-and-multiple -swfs-returning-to-a-previously-loaded-swf

http://stackoverflow.com/questions/19536000/load-and-reload-external-s wf-in-air-for-ios?lq=1

http://blogs.adobe.com/airodynamics/2012/11/09/packaging-and-loading-m ultiple-swfs-in-air-apps-on-ios/

 

Is there any way to reload a secondary swf within an ios application?

Translate

178 Views   2 Replies   Latest reply: Colin Holgate, Dec 8, 2013 7:22 PM

Was this helpful? Yes   No

1.4morrone,

 

Dec 8, 2013 7:11 PM   in reply to NamitaM

Report

Apparently you can't. Check out this page, the SWF reloading section. I was struggling was this same problem for two weeks until I completely changed my app to just not need to load external SWFs. It turns out it was for the better.

 

http://blogs.adobe.com/airodynamics/2012/11/09/packaging-and-loading-m ultiple-swfs-in-air-apps-on-ios/

 

2.Colin Holgate,

The link you gave was the same link that had already been given, and that points to an article about AIR 3.6.

I’m not sure if AIR 3.9 has changed fundamentally with regard to this problem though, but here’s a work around someone used, to make the subsequent loads seem like a new file:

 

https://gist.github.com/sportebois/6969008

 

Would it be possible to just keep a reference to the loaded swf, after the first load? Then you can removechild it when you’re not needing it, and addchild it back when you do need it.

Was this helpful? Yes   No

 

 

 

=================================

=================================

=================================

 

 

 

 

반응형


관련글 더보기

댓글 영역