15 Replies Latest reply: May 11, 2011 11:08 AM by David Causy RSS

    TypeError: Error #1009: Cannot access a property or method of a null object reference.

    scasey1982 Community Member

      I am having a problem with this error when I am trying to use a function for a button.  Everything works fine when I have it on frame 1, but when I add a preloader to frame 1 and put my content on frame two I recieve the #1009 error.

       

      When I tested my code with just a simple function I still got the error.  the code is below, Any help would be greatly appreciated!

      ****Code for Preloader(Frame1)*******

      stop();

      loaderInfo.addEventListener(ProgressEvent.PROGRESS, updatePreloader);

       

       

      function updatePreloader(evtObj:ProgressEvent):void
      {
          var percent:Number = Math.floor((evtObj.bytesLoaded*100)/evtObj.bytesTotal);
          preloader_txt.text=percent+"%";
          if (percent>=100){
              nextFrame();
          }
             
      }

       

       

      ****Code for Main Content (Frame 2)****

       

      stop();
      //Import the necessary files for all of the tweening
      //--------------------------------------------------------
      import fl.transitions.Tween;
      import fl.transitions.TweenEvent;
      import fl.transitions.easing.*;

       

      //---------------------------------

       

      //Move all of the text off screen and set them invisible
      //--------------------------------------------------------
      featuresText_mc.alpha=0;
      featuresText_mc.y=-500;
      viewCottageText_mc.y=-500;
      rateInfo_mc.alpha=0;
      rateInfo_mc.y=-500;
      viewCottageText_mc.alpha=0;

      contactInfoText_mc.alpha=0;
      //--------------------------------------------------------
      viewCottage_btn.addEventListener(MouseEvent.CLICK, goCottage); function goCottage(evtObj:MouseEvent){
          trace("test")
      }

       

      ***Any Help would be greatly Appreciated***