Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
Locked
0

Loading local swf files from Application Dir (ios)

New Here ,
Oct 28, 2013 Oct 28, 2013

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-io...

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!

TOPICS
Development
4.5K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Oct 28, 2013 Oct 28, 2013

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 (i

...
Translate
LEGEND ,
Oct 28, 2013 Oct 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-io...

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 28, 2013 Oct 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 28, 2013 Oct 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 28, 2013 Oct 28, 2013

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 28, 2013 Oct 28, 2013

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 28, 2013 Oct 28, 2013

Thanks Sinious for the detailed help, I appriciate it.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 28, 2013 Oct 28, 2013

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.

I haven't tried this one and most probably that will be the solution.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 28, 2013 Oct 28, 2013

It probably is, the guides tell you to do it. Perhaps it's a schema change in a newer version of AIR that went unnoticed when they overhauled it to allow loading remote SWFs with ABC (that've been stripped).

You're welcome and good luck!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 29, 2013 Oct 29, 2013

I just tried what you suggested but still no luck

If I don't include the <externalSwfs>swfs/swfs.txt</externalSwfs> node in the application descriptor xml it doesn't strip my additional swf file and don't want to load it. I tried to include it then copy the stripped swf and override the external swf with the stripped one but in this case the compiler is complaining "This is not an ABC file" and doesn't even finish compiling the project.

May I ask you to zip that sample you tried and send it to me to velykovits at gmail email address please and I can give it a try myself what can be the reason I am not able compile it?

Thanks for your help in advance Sinious!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 29, 2013 Oct 29, 2013

Sure, here's a project that's missing apple certs but using the command I gave above will compile. I'm doing this from a remote location but I believe the original source rotated 500 random characters every second from the loaded stripped SWF and I saved it down to Flash CS5.

Example Source

You'll need to change the certs to your own to compile. Just a very simple example.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 30, 2013 Oct 30, 2013

I tested your project, replicated the same files using Flash Builder and it looks like if you compile the external swf using an older format (for example I chose Air 3.4 and I compiled the ipa with 3.9) that causes the problem.

Thanks for your help again!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 30, 2013 Oct 30, 2013

Ah, if I knew you preferred that I would have given a Flash Builder 4.7 project. I never produce any apps in Flash Pro, I just use it for app assets. A factory. But you definitely need to make sure anything that has code is exported with the correct compile version where the features you need are introduced (in this case AIR 3.6).

Glad you got it worked out and good luck!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 28, 2014 Jan 28, 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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 30, 2014 Jan 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 30, 2014 Jan 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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 30, 2014 Jan 30, 2014
LATEST

The resolution itself was to make sure SWFs previously compiled used the correct version of AIR to strip, to clarify.

As for the blog, that's the nature of the beast. A post that can be updated but is usually left at the time of posting, only updating as needed. We're all pretty salty seasoned AIR updaters here so I think we'll all know to update the namespace and recompile without the blog telling us .

And again, you're free to post the source. Many people here wear multiple hats so if you coded it in Java, AIR, .NET, etc we'll all be able to make use and even extend the automation. It's the nature of Flash Pro users to lack a comprehensively updated publish panel so it might even be worth opening a GitHub project others can contribute to.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines