5 Replies Latest reply on Nov 22, 2008 5:09 AM by cafesilencio

    Loader doesn't dispatch events after update to AIR 1.5

    cafesilencio
      I had some code working in one of my applications for a long time that stopped working after updating to AIR 1.5. I'll post a code snippet below but basically I use the Loader to load a file from a remote host and listen for the the Event.Complete event but it never gets dispatched. Using Charles I can see the file gets downloaded. Also when debugging the code in Eclipse the code gets to my event handler if i set a break point in it and also trace statements indicate the event handler is reached also but if I export to an AIR application and run the app. the events don't get dispatched. This just started happening after updating to the AIR 1.5 run time.

      <?xml version="1.0" encoding="utf-8"?>
      <mx:WindowedApplication xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute" width="400" height="400">
      <mx:Script>
      <![CDATA[
      import mx.controls.Alert;

      private function launch():void
      {
      var airSWFLoader:Loader = new Loader();
      var loaderContext:LoaderContext = new LoaderContext();
      loaderContext.applicationDomain = ApplicationDomain.currentDomain;

      airSWFLoader.contentLoaderInfo.addEventListener(Event.COMPLETE,onComplete);
      airSWFLoader.contentLoaderInfo.addEventListener(Event.INIT,onInit);
      airSWFLoader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR,handleIOError);
      airSWFLoader.contentLoaderInfo.addEventListener(HTTPStatusEvent.HTTP_STATUS,httpStatus);

      airSWFLoader.load(new URLRequest(" http://airdownload.adobe.com/air/browserapi/air.swf"),loaderContext);
      }


      private function onInit(e:Event):void
      {
      Alert.show("INIT event received","",Alert.OK);
      }

      private function onComplete(event:Event):void
      {
      Alert.show("COMPLETE event received","",Alert.OK);
      }

      private function handleIOError(event:IOErrorEvent):void
      {
      Alert.show("ioError event received","",Alert.OK);
      }

      private function httpStatus(event:HTTPStatusEvent):void
      {
      Alert.show("HTTP_STATUS event received","",Alert.OK);
      }

      ]]>
      </mx:Script>
      <mx:Button x="147" y="152" label="Button" click="launch()"/>
      </mx:WindowedApplication>