5 Replies Latest reply on Jun 17, 2009 9:39 AM by Flex harUI

    Cannot convert SystemManager to SystemManager when loading a swf from outside current folder?

    Maxskunk

      I am working on an AIR application that needs to load, run, and access methods on a swf pulled in from the net. Using moduals has worked well in the past but due to design constraints is not possible for this application. Below you can see the code where I load the ImageTest.swf then call function Bleh() on it.

       

      private var l:Loader = new Loader();                

      private var ctx:LoaderContext;               

      private function onInit():void   

      {                        

           l.contentLoaderInfo.addEventListener(Event.COMPLETE,onLoadComplete);  

           l.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR,onLoadError);

           l.load(new URLRequest("ImageTest.swf"));

      }                 

      private function onLoadError(event:IOErrorEvent):void      

      {                

      }                 

      private function onLoadComplete(event:Event):void

      {                       

           ui.addChild(event.target.content);

           SystemManager(event.target.content).addEventListener(FlexEvent.APPLICATION_COMPLETE, swfAppComplete);

      }                

      private function swfAppComplete(event:FlexEvent):void               

      {                       

           var sys:SystemManager = SystemManager(event.currentTarget);

           var app:Object = sys.application;                        

           app.Bleh();               

       

      This works fine when the swf is local to the AIR application, but when ImageTest.swf is off on a server, it loads fine but I get a coercion run time error(TypeError: Error #1034: Type Coercion failed: cannot convert _Engine_mx_managers_SystemManager@7c36281 to mx.managers.SystemManager) at the line:


      SystemManager(event.target.content).addEventListener(FlexEvent.APPLICATION_COMPLETE, swfAppComplete);

       

      I believe the error might be relating to a security sandbox issue, but I am not sure. Thanks in advance!