1 Reply Latest reply on Sep 6, 2006 6:32 AM by isml

    very very weird issue about SWFLoader and SystemManager

    isml Level 1
      SWLoader works well when there are only two levels. I mean in the main swf i use SWFLoader to load a child swf, but if in the child swf, i load another swf, called grandchild swf, problems come out.

      Here is an example, I have three swfs, Test.swf, Test1.swf, Test2.swf, and their relationship is: Test.swf loads Test1.swf, and Test1.swf loads Test2.swf.

      Codes:

      Test.mxml:
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="vertical" >
      <mx:Script>
      <![CDATA[
      private function LoadTest1():void
      {
      ldrTest1.load();
      }
      ]]>
      </mx:Script>

      <mx:SWFLoader id="ldrTest1" source="Test1.swf" autoLoad="false" width="100%" height="100%" />
      <mx:Button label="LoadTest1" click="LoadTest1()" />
      </mx:Application>

      Test1.mxml:
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" backgroundColor="#FF0000" layout="vertical" creationComplete="OnInit()">

      <mx:Script>
      <![CDATA[

      import mx.controls.Alert;
      import mx.managers.SystemManager;

      private function OnInit():void
      {
      Application.application.parameters.InitComplete = InitComplete;
      }

      private function InitComplete():void
      {
      Alert.show("<Test1> InitComplete");

      var smPlugin:SystemManager = SystemManager(ldrTest2.content);
      var hPlugin:Test2 = Test2(smPlugin.application);
      hPlugin.Announce();
      }


      private function LoadTest2():void
      {
      ldrTest2.load();
      }

      ]]>
      </mx:Script>

      <mx:Button label="LoadTest2" click="LoadTest2()">
      </mx:Button>

      <mx:SWFLoader id="ldrTest2" source="Test2.swf" autoLoad="false" width="100%" height="100%" />
      </mx:Application>

      Test2.mxml:
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" backgroundColor="#00FF00" layout="vertical" creationComplete="OnInit()">

      <mx:Script>
      <![CDATA[

      import mx.controls.Alert;

      private function OnInit():void
      {
      Application.application.parameters.InitComplete();
      }

      public function Announce():void
      {
      Alert.show("<Test2> Announce");
      }

      ]]>
      </mx:Script>

      <mx:TextArea width="100%" height="100%" />
      </mx:Application>

      I received a run-time error, which meant I could not convert Test2@3dc6851 to Test2. I just do not know what it means. But it really works if i only use Test1.swf to load Test2.swf.

      So I doubt there may be something i do not know with SystemManager. I wonder whether it only works in Main Swf, not Loaded Swf.

      Have you met such problem? Any help will be appreciated.