1

I basically lumped all the buttons in a Movie Clip so that i don't have to individually make a MouseClicked function for a lot of buttons. It works when you test it on it's own but when i put it in another scene that redirects to it it shows an error

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

this is my code for it

  buttonsClip.addEventListener(MouseEvent.MOUSE_DOWN, handleButtons, false, 
   0,true);

    /** Button Handler */
    function handleButtons(e:Event)
    {
         /** e.target is the actual button that is being pressed. */
         trace(e.target.name);

    timer1.start();
    wrongBush.visible = true;
    fl_SC = s.play();
        stop();

    }
  • which line is throwing the error? From this code, it means that either `buttonClip`, `timer1` `wrongBush` or `s` are null. – BadFeelingAboutThis Jul 05 '17 at 16:44
  • its buttonsClip according to debug but i don't really get why it does that. – maggotypeach Jul 05 '17 at 16:53
  • heres the other errors: at flash.display::Sprite/constructChildren() at flash.display::Sprite() at flash.display::MovieClip() at flash.display::MovieClip/gotoAndStop() at map_fla::MainTimeline/fl_ClickToGoToAndStopAtFrame()[map_fla.MainTimeline::frame1:6] – maggotypeach Jul 05 '17 at 16:54
  • There isn't much help that can given with the information available. Make sure that where this code runs `buttonsClip` exists and has that instance name. – BadFeelingAboutThis Jul 05 '17 at 17:01
  • I fixed it by turning buttonsClip into a button instead of movieclip. tnx all for responding – maggotypeach Jul 05 '17 at 17:10

0 Answers0