1 Reply Latest reply on Jun 21, 2010 4:29 AM by Booya2nd

    Why the second loader doesn't work?

    learner_7n Level 1

      Hi,

       

      If I keep the first following action script (Adobe Flash CS4 Action Script 3) which is in BLUE it is workng fine. But If I keep the both action scripts which are in BLUE & RED. It shows nothing. What is the problem with the next one. Please do help.

       

      var l:Loader=new Loader();
      addChild(l);

      l.load(new URLRequest("MyLogo.swf"));
      l.x = 10;
      l.y = 100;

      l.contentLoaderInfo.addEventListener(Event.INIT, growLoader);

      function growLoader(evt:Event):void {

           l.width = 150;

           l.height = 150;
      }

       

      var k:Loader=new Loader();
      addChild(k);

      k.load(new URLRequest("MyBanner.swf"));
      k.x = 200;
      k.y = 100;

      k.contentLoaderInfo.addEventListener(Event.INIT, growLoader);

      function growLoader(evt:Event):void {

           k.width = 500;

           k.height = 150;
      }

       

      Thanks and regards.

        • 1. Re: Why the second loader doesn't work?
          Booya2nd Level 2

          Hi there,

           

          the error is caused by accidently overriding yout handler function   growLoader()  .

          You will have to define two handlers to solve the problem:

           

          var l:Loader=new Loader();
          addChild(l);

          l.load(new URLRequest("MyLogo.swf"));
          l.x  = 10;
          l.y = 100;

          l.contentLoaderInfo.addEventListener(Event.INIT,  growLogoLoader);

          function growLogoLoader(evt:Event):void {

               l.width = 150;

               l.height = 150;
          }

           

          var k:Loader=new Loader();
          addChild(k);

          k.load(new URLRequest("MyBanner.swf"));
          k.x  = 200;
          k.y = 100;

          k.contentLoaderInfo.addEventListener(Event.INIT, growBannerLoader);

          function growBannerLoader(evt:Event):void {

               k.width = 500;

               k.height = 150;
          }

           

          it is not tested, but this should do the trick.