5 Replies Latest reply on Jun 19, 2010 11:15 AM by Ned Murphy

    Second loader not working

    learner_7n Level 1

      Hi,

       

      The following action script for loader is working fine:

       

      var l:Loader=new Loader();

       

      addChild(l);

       

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

       

      But when I added one more loader to it like the following...It doesn't show anything but gives an error:

       

      var l:Loader=new Loader();

       

      addChild(l);

       

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

       


      var 2:Loader=new Loader();

       

      addChild(2);

       

      2.load(new URLRequest("Plant.swf"));

       

      The error is: Syntax error: expecting identifier before 2.

       

      What does it mean and how to solve the problem?

       

      Regards.

        • 1. Re: Second loader not working
          Ned Murphy Adobe Community Professional & MVP

          Do not use a number as an instance name/variable.  In case you think the first is using a "1", it is not, it is a lower case L.

          1 person found this helpful
          • 2. Re: Second loader not working
            learner_7n Level 1

            Fantastic. It is fine both are working now. But the problem is one logo sits on another. So I can see only one logo after animation. I don't see any logo on my stage to re-position it on different locations unless I run my movie. Further help needed to resolve the problem. Since I am new to flash asking several questions. Please forgive me.

             

            Regards.

            • 3. Re: Second loader not working
              Ned Murphy Adobe Community Professional & MVP

              Set the x and y properties of your loaders to be where you want them...

               

              l.x = 100; // just an example

              l.y = 100;

              1 person found this helpful
              • 4. Re: Second loader not working
                learner_7n Level 1

                Ned Murphy wrote:

                 

                Set the x and y properties of your loaders to be where you want them...

                 

                l.x = 100; // just an example

                l.y = 100;

                 

                Quite nice. Working great. Can I resize it through code? When I tried like the following the logo disappered completely.

                 

                l.width =200;
                l.height =200;

                 

                What is the correct way?

                 

                Best regards.

                • 5. Re: Second loader not working
                  Ned Murphy Adobe Community Professional & MVP

                  You have to wait until the file being loaded is fully loaded before you can try to change width/height properties of the Loader--without content, the loader has no width/height.  You'll need a listener to listen for the INIT event of the contentLoaderInfo property of the Loader.

                   

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

                   

                  function growLoader(evt:Event):void {

                       l.width = 200;

                       l.height = 200;

                  }

                   

                  Please mark this posting as answered, and if you have new questions, start new postings.  It helps others looking for help when you stick to the topic in the title.

                  1 person found this helpful