Skip to main content
Inspiring
December 20, 2012
Question

AIR app to build with files it will load.

  • December 20, 2012
  • 1 reply
  • 909 views

Hi everyone !

I was wondering today if my AIR app could load pictures, texts during runtime, so no embedding.

I mean, when the users installs my app, the needed files the app will later load (when opened) are also installed in app's directory.

How can I do this ? Is it possible in mobile also (just out of curiosity) ? Or is it just better to not load files every time the app starts ?

This topic has been closed for replies.

1 reply

Ned Murphy
Legend
December 20, 2012

I cannot speak for app best practices, but loading content dynamically is usually the better design decision.  It allows the main file to set up quickly as well as other benefits, such as being able to modify the dynamic content without having to republish the main file.

he11f1reAuthor
Inspiring
December 20, 2012

Alright, great !

Do you know where can I look for instructions for how to bundle the Main.swf and the assets it will load in runtime.

So there's an installer package that when gets installed in user's computer, extracts the assets and the main swf afcourse.

sinious
Legend
December 20, 2012

In flash during publish at the bottom of the General tab you can specify files to be included inside your app. They don't need to be extracted to use, they are automatically placed in your "applicationDirectory".

e.g. (CS5.5 publish settings, yours may look different):

Just to make something clear,  you cannot write to that folder after your application is started. It is read-only:

File.applicationDirectory—the read-only directory where the application is installed (along with any installed assets)

http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/filesystem/File.html

You didn't mention what device you're targeting but there's also rules about storing content that can be re-obtained.

If you have a ton of content that can be updated then my strategy is to use a very tiny XML file which contains version numbers of assets.

e.g.

<?xml version="1.0" encoding="utf-8" ?>

<assets>

    <file id="1" v="2.5"/>

    <file id="2" v="1.0"/>

    <file id="3" v="1.5"/>

    <!-- etc -->

</assets>

If there's potentially hundreds of assets I can quickly traverse my current XML file versus this tiny XML file looking for any newer content. I then only get that content. I pre-bundle the files necessary to start the app to a usable point. That aside..

On iOS, when the user loads my app I check for internet connectivity and then attempt to download the latest version of my content. I store it to the File.applicationStorageDirectory and because iOS regulates that if this content can be recreated or is not vital to the application, I set the "do not backup" bit. For resource I want to share through iTunes (downloaded movies, PDFs, etc) I enable File Sharing via iTunes permission and save to the File.documentsDirectory. Those files can be dragged off the device to my computer for saving.

Android is pretty much the same only I don't need the regulation of the "do not backup" bit.

That was just one example of both an dynamic strategy, prepackage strategy, efficient update strategy and the differences you'll encounter with dynamic content rules from device to device.