12 Replies Latest reply on Oct 5, 2009 1:10 PM by Jake Lyman

    How to add files when exporting air application

    reflexactions

      If I want to add swf modules or say a compiled css file, that are all extern (i.e. there are no explicit references to them in the actual application code) and will be loaded at run time, to an AIR package how do I do it?

      Just to clarify, I can run the app just fine at the moment so long as I manually copy the swfs to the app install folder after installation, so this isnt a question of how to make the app run with run time loaded modules, its about how to get them into the .air file so they get installed initially.

      Thanks

      Rob

        • 1. Re: How to add files when exporting air application
          GregLyon

          Hi Rob,

          This is pretty straightforward:

          1. Just create a new folder inside your Source folder.  (I often use a name such as 'swf')
          2. Place your swfs in the new folder.
          3. Export Release build.  You'll notice that on the 3rd or 4th screen there's a folder list where you can include/exclude files at will.

           

          One caveat with the include/exclude files:  ANY file that is referenced (and embedded) into your app WILL NOT show up as an external asset.

          For this reason I suggest placing all assets that will be embedded into a folder such as 'assets', and ones that won't be in a folder such as 'images'.  If you need myImage.jpg embedded and as an external asset make sure you put a copy in each folder.

           

          I've built some fairly extensive Air apps that include dozens of Captivate swfs that are referenced from an external XML file, and this is how I do it.

          Greg.

          • 2. Re: How to add files when exporting air application
            reflexactions Level 1

            Many thanks!

            I found that FB won't copy the contents of the folder under src if that folder is just linked in (which was how I set it up as these swf's were being built in another FB Application), only seems to work if the folder is a 'physical' folder under src.

             

            Once I realized that everything was good.

             

            Thanks

            Rob

            • 3. Re: How to add files when exporting air application
              GregLyon Level 1

              Good to know, Rob. I hadn't ever tried that ( but probably would have eventually).  I've had good luck writing scripts to copy in the files I want, and some of the other Devs here are starting to use ANT scripts to automate builds...after the learning curve that may be the way to go if your setup is at all complex.

               

              Cheers,

              Greg.

              • 4. Re: How to add files when exporting air application
                Jake Lyman

                Hey guys,

                 

                Your discussion was helpful. Thanks for having it.

                 

                I have a follow up question:

                 

                When I right click my air app on a Mac, I am presented with an option to "Show Package Contents". I do not have access to a Windows box and would like to see how to open the package on a Windows machine. I need to help someone replace some images in an air app that resides on a Windows machine.

                 

                Thanks so much!

                • 5. Re: How to add files when exporting air application
                  GregLyon Level 1

                  Hi Jake,

                  While I have found that I can view the windows .air file using programs like WinRAR etc, I haven't found a way around recompiling the .air file.  I have to use Flex or SDK when I need to update files in the air package.  Attempting to do-so using my ZIP program corrupts the air package.

                  • 6. Re: How to add files when exporting air application
                    Jake Lyman Level 1

                    Hi Greg,

                     

                    Thank you for taking the time to respond. This leads me to another question. How do I set things up, then, to allow a non-flash/flex person to update images or change an xml file that contains text and urls to assets? Ultimately what I'm going for here is a way to update the app without having to recompile. Is there a way to have an assets folder that is external to the AIR app, but right alongside it, rather than have the assets folder reside within the src folder and therefor within the AIR package?

                     

                    I'm realizing I should have looked into this before starting the app. I typically create Flex apps that are browser based and so the assets folder doesn't get "consumed" by the .swf. Anyone can swap out an image in that environment.

                     

                    Thanks again for weighing in on this,

                     

                    Jake

                    • 7. Re: How to add files when exporting air application
                      Joe ... Ward Level 4

                      Because AIR files are signed, changing anything in the package will invalidate the signature and prevent the application from installing. This is a security precaution.

                       

                      To include a separate folder outside the AIR application from which to load assets, you would have to either create your own installer that installed the AIR application and the assets in separate steps, or you could have the AIR application download the assets on first run (from the network, or a CD).

                       

                      An intermediate process would be to compile your application as normal in Flex Builder, but perform the packaging/signing (which isn't 'compiling' anything) as a separate step.  The assets could then be changed between compilation and packaging. A batch file or Ant script could be used for the packaging step so that your non-flash/flex person doesn't have to run FB.

                      • 8. Re: How to add files when exporting air application
                        GregLyon Level 1

                        Jake, that's exactly where my team is stuck...

                         

                        Here's my similar (and unanswered) Question:

                        http://forums.adobe.com/thread/492989?tstart=120

                         

                        We don't see a way to use the AIR packager to install content and images external to the package.  So far we're stuck there.  I REALLY wish I had an answer on that for you (and me).

                        • 9. Re: How to add files when exporting air application
                          GregLyon Level 1

                          Hi Joe,

                          Thanks for your input.  I will have to take a close look at the run-once concept for installing assets after the air package is installed.  It may be just what we need.


                          Greg.

                          • 10. Re: How to add files when exporting air application
                            Jake Lyman Level 1

                            Hi Joe,

                             

                            Thanks for the input. May I ask a series of follow up questions?

                             

                            1. If I choose curtain #2, "have the AIR application download the assets on first run," I'm guessing I use the File, FileMode, and FileStream classes to accomplish this.

                             

                            2. If #1 is correct, do you happen to know how I would make the file path to those assets relative, regardless of OS? Would it be by using "app:/" at the beginning of the file path in order to target the application directory?

                             

                            3. If #2 is correct, does that mean I can throw a folder in the same directory as the installed AIR app with assets in it that the application can use?

                             

                            Hope I'm heading in the right direction with my thoughts...

                             

                            Thanks again,

                             

                            Jake

                            • 11. Re: How to add files when exporting air application
                              Joe ... Ward Level 4

                              1. If you are distributing the app on a CD, then yes, you would use the File and related classes to do the copy. If the assets are available on the internet, you would use the URLLoader class instead.

                               

                              2, 3. You can't use the application directory for this. I would recommend using the app-storage directory. Use the File.applicationStorageDirectory to get a File object representing this directory on a given client system. (The app directory is write-protected on OS's like Vista with certain settings.) One possible complication here is that the assets are no longer in the application security sandbox. That usually won't matter for things like images, videos, and text, but for SWF and CSS assets, you then have to deal with sandbox issues.

                              • 12. Re: How to add files when exporting air application
                                Jake Lyman Level 1

                                Thanks, Joe.

                                 

                                I'll take a look at the docs for File.applicationStorageDirectory.

                                 

                                Appreciate the shove in the right direction!

                                 

                                Jake