Jump to content
Search Community

ghassett

Members
  • Posts

    2
  • Joined

  • Last visited

Posts posted by ghassett

  1. Hello, I am using LoaderMax to load assets from a web server when my AS3/AIR game starts. Assets might be PNG files (using ImageLoader) or SWF's (using SWFLoader). I would like to cache the content in persistent storage -- since I am using AIR, this would be mean storing the cache in the computer's file system or the mobile device's application storage area, so that the next time my game is run, I do not have to reach out to the server and re-download the assets. I could use code like the following:

     

    var file:File = File.applicationStorageDirectory.resolvePath ("test_cache_as3");

     

    var fileStream:FileStream = new FileStream();

    fileStream.open(file, FileMode.WRITE);

    fileStream.writeObject(... my image/SWF ...);

     

    But then I need to figure out how to serialize images and SWF's -- which doesn't appear to be an obvious thing to do. I tried with images, by calling

     

    registerClassAlias ("Bitmap", Bitmap);

    registerClassAlias ("BitmapData", BitmapData);

    registerClassAlias ("Transform", Transform);

     

    and then storing Bitmap's in a Dictionary keyed by their URL... reading the images back in caused headaches with the bitmap's BitmapData member.

     

    Any advice or suggestions? This seems like it might be a common need (cacheing the results of URL fetches), so I feel like I am missing something obvious.

     

    Thanks so much for your help!

×
×
  • Create New...