2 Replies Latest reply on Feb 4, 2009 11:22 AM by tzeng

    Problem with Loader class in AIR

    w_danilo
      Hi, I've recently written a part of a small application, but I can not pass throught an error - I've asked about it in another forums, but nobody knows the answer so the probelm is that:
      1) I've created a Loader; it loads swf file inside.
      2) When I apply to complete handler of theseloader a function, which adds this loader to the stage (methods: rawchildren.addChild(...) or It creates new UIComponent, which is added to the stage and inside this component the loader) - everything is ok - I see the result on the sage, but:
      3) When complete handler makes nothing and i apply these loader to the stage by button-function ... nothing happens? - I can't see anything new on the stage. Why? (quick example attached below).
      I reallyplease about your help! :):):)

      (complete flex project: http://danilo.ocom.pl/arch.rar )

      (FLEX) WHEN YOU CREATE PROJECT AND USE CODE1 IT WORKS, BUT WITH CODE2 AFTER PRESSING BUTTON NOTHING HAPPENS. WHY?

      CODE1:
      <?xml version="1.0" encoding="utf-8"?>
      <mx:WindowedApplication xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute" initialize="init()">
      <mx:Script>
      <![CDATA[
      var loader:Loader=new Loader();

      function init()
      {
      loader.load(new URLRequest("test.swf"));
      loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadCompleteH);
      }
      function c1()
      {
      rawChildren.addChild(loader);
      }
      function loadCompleteH(event)
      {
      c1();
      }
      ]]>
      </mx:Script>
      </mx:WindowedApplication>

      CODE2:
      <?xml version="1.0" encoding="utf-8"?>
      <mx:WindowedApplication xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute" initialize="init()">
      <mx:Script>
      <![CDATA[
      var loader:Loader=new Loader();

      function init()
      {
      loader.load(new URLRequest("test.swf"));
      loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadCompleteH);
      }
      function c1()
      {
      rawChildren.addChild(loader);
      }
      ]]>
      </mx:Script>
      <mx:Button click="c1()"/>
      </mx:WindowedApplication>