Skip to main content
Known Participant
October 28, 2013
Answered

Loading local swf files from Application Dir (ios)

  • October 28, 2013
  • 2 replies
  • 4447 views

Hi Guys,

I would like to load additional local swf files to my ios release build but I am confused a little bit because of the new API changes.

As far as I know at the moment (from Air 3.7 or newer) it is allowed to load local swf files that contains compiled actionscript both from local folder and from a predefined remote host as well. 

My assumption based on this article:

http://blogs.adobe.com/airodynamics/2013/03/08/external-hosting-of-secondary-swfs-for-air-apps-on-ios/

I created the text file to include all of my local swf file names and created the following node in the application.xml:

<iPhone>

  .

       <externalSwfs>assets/SampleSWFInfoFile.txt</externalSwfs>

       .

</iPhone>

When I compile the release build (ipa) using command line adt, it converts all of my local swfs into the stripped swfs which is perfect, but even though I include all the swfs in the compiler command, it puts only the SampleSWFInfoFile.txt file into the assets folder in the ipa but not the swf files.

I assume, it thinks I will load these files from an external host, but I would like to include them in the app itself.

I tried to copy the stripped swf files from the externalStrippedSwfs folder and comment the <externalSwfs>assets/SampleSWFInfoFile.txt</externalSwfs> node in the application.xml and compile it and this way it puts the swf files into the ipa, but when I try to install and launch the app it crashes and when I test it using Flash Builder it shows an error message

"VerifyError: Error #1042: Not an ABC file."

Do any of you guys know the  solution for this problem?

Thank you for your help in advance!

This topic has been closed for replies.
Correct answer sinious

...I have a feeling the step what I missed is to compile the external swf in AOT mode, but I am not sure yet.


You're publishing in AOT mode as long as you use one of these:

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.

Flash Pro CS6 and Flash Builder automate this process pretty well so it's invisible but the SWF loads and executes code just fine for me when directly published.

If I take it to command line I can use this to compile successfully (iPad test app):

adt -package -target ipa-ad-hoc -storetype pkcs12 -keystore my.p12 -provisioning-profile my.mobileprovision NameOfApp.ipa NameOfApp-app.xml NameOfApp.swf iTunesArtwork iTunesArtwork@2x AppIconsForPublish swfs/swfs.txt swfs/GenerateText.swf

I at least include generic icons in there but I made a 'swfs' folder and placed 'swfs.txt' and 'GenerateText.swf' in there. The SWF uses code to randomly generate text and changes every second using a Timer. I load it in using the same code you do with the ApplicationDomain.currentDomain context. I see the SWF appear and text start randomly changing.

As I compile there's a folder generated called 'externalStrippedSwfs' with the stripped SWF in there.

One thing to note is I do not supply <externalSwfs>swfs/swfs.txt</externalSwfs> in my iPhone settings. If I do that it doesn't work. I supply the path to the text file containing the SWF I want to be stripped to adt itself along with the SWFs I want stripped and it takes care of the rest.

2 replies

Participant
January 29, 2014

Hey all,

Since I am struggling with the same problems, I developed a tiny application for automatic creation of the text file with all .swf files + adt command

In case you like to try it, you can download it from here:

[Removed unverified link]

It doesn't require any setup, just run it and create your files.

Hope it helps anyone interested.

Message was edited by: sinious

sinious
Legend
January 30, 2014

That's nice of you cafeine_01 but this issue has evolved/resolved in later versions of AIR and since we cannot verify your executable is safe to run I must remove the link.

Thanks and feel free to post a link to the source code itself for compiling, that is perfectly fine as long as we can see what the code is actually doing.

Participant
January 30, 2014

Hello sinious and thanks for your message, I understand security issues, sorry for spamming some threads with same message/application link....got too excited writing code at 5am ....and great news about issue being resolved. Should the blog post describing air to ios workflow be updated to air 3.9 / 4.0?

Thanks.

Konstantinos

sinious
Legend
October 28, 2013

Try this (Introduced in AIR3.6), loading local SWFs with ABC:

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

In 3.7 they allowed "remote" hosting so by default the stripped SWFs ABC is going to be compiled into the main IPA and then explicitly excluded from the IPA itself. It then expects you to remote host them. The docs tell you that these SWFs will be excluded (read here):

- Transfers the ABC code from each externally loaded SWF to the main executable.

- Omits the externally loaded SWFs from the .ipa file.

- Copies the stripped SWFs to the .remoteStrippedSWFs directory. You host these SWFs on a web server and your application loads them, as necessary, at runtime.

The AIR3.6 local version still does stripping because the code needs to be compiled. There is no runtime to real-time run ABC so it does need to get stripped and compiled prior to package.

VejkoAuthor
Known Participant
October 28, 2013

Thanks Sinious for your help.

I tried that too but it looks like it cannot load the file.

As far as I can see, adl converts the external swfs to the stripped ABC swf format and adds to the ipa, but when I install the app and try it, it doesn't load the swf file

I load the swf with a LoaderContext instance to set the applicationdomain but still no luck.

VejkoAuthor
Known Participant
October 28, 2013

This is the adl command I use:

adt -package -target ipa-ad-hoc -provisioning-profile ios.mobileprovision -storetype pkcs12 -keystore cert.p12 -storepass password Test.ipa ExternalSWFLoadingText-app.xml ExternalSWFLoadingText.swf ./assets/Ext1.swf

If you can spot a possible typo or any logical mistake I would be very glad but as far as I know this is the correct usage.