2 Replies Latest reply on Jun 5, 2009 9:47 AM by junior_helio

    help with simple Preloader. Error#1009  :-(

    junior_helio Level 1

      Hello !


      I have a very simple preloader file which loads a "main.swf" file. I put on stage

      a LogoCompany (MovieClip), a Mask (MovieClip) and a Text (Dynamic).


      As the percentage of bytes from the .swf file increases, the Mask.x position is increased so the LogoCompany appears.


      Here is the code:


      // Simple Preloader
      var maskStart:Number = 116;
      var maskEnd:Number = 377;
      var maskMove:Number = maskEnd - maskStart;
      var myLoader:Loader = new Loader();


      // URL to swf.
      myLoader.load( new URLRequest("main.swf") );


      // Create event
      myLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, myLoop);


      function myLoop(e:ProgressEvent):void
          var perc:Number = Math.round( (e.bytesLoaded / e.bytesTotal) * 100);
          trace ("perc == " + perc);
          txtMessage.text = "Loading... " + perc.toString() + "%";
          trace ("txtMessage.text == " + txtMessage.text);
          maskLogo_mc.x = maskStart + maskMove * perc / 100;
          trace ("maskLogo_mc.x == " + maskLogo_mc.x);
          if(e.bytesLoaded == e.bytesTotal)
              txtMessage = null;



      The animation is actually going till the end (100%).  But in the middle I always get this error:


      TypeError: Error #1009: Cannot access a property or method of a null object reference.
          at main_fla::MainTimeline/main_fla::frame13()

      I really don't know what is going on.


      Can anyone help me with this ?


      Thanks in Advance.



        • 1. Re: help with simple Preloader. Error#1009  :-(
          Ned Murphy Adobe Community Professional & MVP

          One thing you should do is move the progress event listener and the handler function before the load command with the function ahead of the listener.  It's just better to have everything set up before the code that's going to use it.


          Another thing you can try is to go into your Flash publish settings and put a check in the allow debugging option.  It can usually give you a little more pointed results in your error messages.  It may point to a line number or the name of the offender.

          • 2. Re: help with simple Preloader. Error#1009  :-(
            junior_helio Level 1

            Hello Ned.


            Thank you for your prompt reply.


            Unfortunately I got the same error after I followed your suggestions:


            - Moving the .load() function after everything.

            - Marking "Permit Debugging" on Publish Settings under Flash tab. (CS3 version here)




            Any more suggestions?


            Thanks in advance.