Hi all,

I am using AIR 1.5 SDK.
I am trying to find a way to build patching mechanism for my AIR app, which 
consists modules, sqlite DBs, and other files, by updating ONLY files that need 
to be updated.

I know that this is not possible using AIR Update Framework because the way I 
understand it works is that any update that you have both minor and major, you 
will have to reinstall everything. This is a pain if you have a huge size AIR 
app.

I have sort of an idea to build my own update mechanism but in order for this 
to work, I will need to be able to do update operation on my AIR app files.

Since "app" domain doesn't allow us to do that, I have to find a place where 
updates can take place and my app could still work. I read that "app-storage" 
allows you to do all of that.

Okay... so I build a really simple AIR app that the sole purpose is to load swf 
module from "app-storage" to prove my theory.

So here's my AIR app code the short version:

<mx:WindowedApplication>
   <mx:Script>
        private function loadSwf():void
        {
                  var dir:File = File.applicationStorageDirectory
                  dir = dir.resolvePath("SimpleSwf.swf");//SimpleSwf is the 
module
                 
                  var myURLRequest:URLRequest = new URLRequest(dir.url);
                  var myURLLoader:URLLoader = new URLLoader();
                  myURLLoader.dataFormat = URLLoaderDataFormat.BINARY;
                  myURLLoader.load(myURLRequest);
                  
myURLLoader.addEventListener(Event.COMPLETE,loadModuleCompleteHandler);
        }

         private function loadModuleCompleteHandler(pEvent:Event):void
            {
                  var context:LoaderContext = new LoaderContext();
                  context.allowLoadBytesCodeExecution = true;
                  context.applicationDomain = ApplicationDomain.currentDomain;
                 
                  var moduleLoader:Loader = new Loader();
                  var loader:URLLoader = URLLoader(pEvent.target);
                  moduleLoader.loadBytes(loader.data,context);
           
                  container.addChild(moduleLoader);
            } 
    </mx:Script>

   <mx:VBox width="100%" height="100%">
        <mx:Button label="Load SWF" click="loadSwf()"/>
        <mx:UIComponent id="container"/>
   </mx:VBox>
</mx:WindowedApplication>

The result is:
When I click the button "Load SWF", I could see that the loader loads the SWF 
correctly (it got the right size, etc) but I didn't see the module shows up on 
the screen at all.
I didn't know what I do wrong.

Please enlighten me.

Reply via email to