1 Reply Latest reply on Dec 29, 2010 4:14 AM by flex2008

    Why the hell does not SWFLoader Event.COMPLETE ?!?

    VirtualCoder Level 1

      I have a semi-working flash.display.Loader example - in that its loader.load() works.  However, there are gazillions of resizing and horizontal/vertical positioning nightmares with it - so I came across few articles which state that SWFLoader is much better in that respect.

      HELL IT IS !

       

      <?xml version="1.0" encoding="utf-8"?>

      <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"

         xmlns:s="library://ns.adobe.com/flex/spark"

         xmlns:mx="library://ns.adobe.com/flex/mx"

         applicationComplete="init()"

         >

      <fx:Script>

      <![CDATA[

            import mx.controls.Alert;

           import mx.controls.SWFLoader;

       

       

           public var loader:SWFLoader = new SWFLoader();

       

       

           public function init():void {

                Alert.show('hello');

                loader.addEventListener(Event.COMPLETE, onLoaderComplete);

                loader.load(new URLRequest('http://www.youtube.com/apiplayer?version=3'));

           }

           public function onLoaderComplete(event:Event):void {

                Alert.show('world');

           }

      ]]>

      </fx:Script>

      </s:Application>

        • 1. Re: Why the hell does not SWFLoader Event.COMPLETE ?!?
          flex2008 Level 3

          Use loader.load('http://www.youtube.com/apiplayer?version=3'); and complete event will be triggered.

           

          One thing i want to add.When you say,

          public var loader:SWFLoader = new SWFLoader();

          you are just creating a SWFLoader instance.For it to be seen,it has to be added to the display list,like

          <?xml version="1.0" encoding="utf-8"?>
          
          <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
                         xmlns:s="library://ns.adobe.com/flex/spark"
                         xmlns:mx="library://ns.adobe.com/flex/mx"
                         applicationComplete="init()"
                         >
              <fx:Script>
                  <![CDATA[
                      import mx.controls.Alert;
                      import mx.controls.SWFLoader;
                      
                       /* public var loader:SWFLoader = new SWFLoader(); */ 
                      
                      public function init():void {
                          
                          Alert.show('hello');
                          loader.addEventListener(Event.COMPLETE, onLoaderComplete);
                          loader.load('http://www.youtube.com/apiplayer?version=3');
                          
                      }
                      
                      public function onLoaderComplete(event:Event):void {
                          
                          Alert.show('world');
                          
                      }
                      
                  ]]>
                  
              </fx:Script>
              <mx:SWFLoader id="loader"/>
          </s:Application>