Skip to main content
May 15, 2012
Question

Download Assets at Runtime in SWF Format

  • May 15, 2012
  • 3 replies
  • 1735 views

Hi,

I am developing a game in AIR for mobile that has certain visual assets that may change with the seasons.  Imagine a set of four characters: George, Paul, John, and Ringo.  The images, music, movie clips, etc., for these characters are bundled into a SWF which I donwload from my server at runtime.  At Chrismastime, I replace the SWF file on my server with a Christmas themed version (John's wearing a Santa hat, and the game's theme music takes on a festive tone).

To access the resources in the SWF after I load it from the remote server, I would grab the loader and instantiate classes in ActionScript, with code along these lines (this example is using greensock's LoaderMax):

private function getDisplayObject (name:String):DisplayObject

{

    var ClassRef:Class = _assetsSwfLoader.getClass(name);

   

    if (ClassRef)

    {

        return new ClassRef() as DisplayObject;

    }

    else

    {

        throw new Error("Cannot find class " + name + " in " + _assetsSwfLoader.url);

    }

}

The problem is with iOS.  I don't think that I am allowed to download and crack open a SWF file on iOS, because Apple might consider that "downloadable code" and therefore Adobe's iOS runtime won't allow it.

Am I right?  Wrong?  Is there a way to open SWF files and extract playable movieclips (or other DisplayObjects) on iOS under AIR?

// thanks! // greg //

This topic has been closed for replies.

3 replies

Inspiring
May 15, 2012

I'm not sure, since I have never done this before, but I would try packaging the normal assets in the swf. Download the new images from the server and save them in your applicationStorageDirectory, then when you load them up, check to see if the image file exists in the applicationStorageDirectory. If so, use that one, otherwise, use the default asset. I may be way off, but I would give that a shot.

May 16, 2012

I think the problem is that Adobe's compiled-to-native iOS runtime will not allow downloaded SWF files to be opened at all.  This prevents AIR applications from violating Apple's App Store guidelines which prohibit interpreters of any kind.

Would love to hear from Adobe about this!

Inspiring
May 16, 2012

Well what I was saying is to not download another SWF at all - just the images. I am almost positive you are right about not being able to change out the SWFs... hence the reason seasonal game changes for me always come through an App Store update.