Skip navigation
Currently Being Moderated

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

Jul 13, 2012 6:28 PM

Hey,

I need help to understand what's wrong and what to do in this situation:

 

i'm building a website with 5 menuBtns and 5 frameLabels gotoAndStop . The problem is with 2 btns > on CTRL+ENTER when i click on those 2 i get this error : TypeError: Error #1009: Cannot access a property or method of a null object reference.  .. it took me on the framelabel of the btn but  the animations and actions that i have there don't work.  . What can i do to prevent this or fix it ? pls help me

 

This is the code for my btns:  >>problem btns are  weDance and inFan !

 

stop();

 

// handle events for menu btns

 

weDance_btn.addEventListener(MouseEvent.CLICK, clickWedance);

clubSpace_btn.addEventListener(MouseEvent.CLICK, clickClubSpace);

inFan_btn.addEventListener(MouseEvent.CLICK, clickInFan);

outOfSpace_btn.addEventListener(MouseEvent.CLICK, clickOutOfSpace);

karnivale_btn.addEventListener(MouseEvent.CLICK, clickCarnivale);

 

 

function clickWedance(evtObj:MouseEvent) {

    //trace shows what's happening .. in the output window

    trace("The wedance btn was clicked!");

 

    gotoAndStop("weDance");

}

 

function clickClubSpace(evtObj:MouseEvent) {

    //trace shows what's happening .. in the output window

    trace("The clubspace btn was clicked!");

 

    gotoAndStop("clubSpace");

}

 

function clickInFan(evtObj:MouseEvent) {

    //trace shows what's happening .. in the output window

    trace("The INFAN btn was clicked!");

 

    gotoAndStop("inFan");

}

 

function clickOutOfSpace(evtObj:MouseEvent) {

    //trace shows what's happening .. in the output window

    trace("The outofspace btn was clicked!");

 

    gotoAndStop("outOfSpace");

}

 

function clickCarnivale(evtObj:MouseEvent) {

    //trace shows what's happening .. in the output window

    trace("The carnivale btn was clicked!");

 

    gotoAndStop("karnivale");

}

 
Replies
  • Currently Being Moderated
    Jul 13, 2012 6:41 PM   in reply to bogdano.

    The 1009 error indicates that one of the objects being targeted by your code is out of scope.  This could mean that the object....

     

    - is declared but not instantiated

    - doesn't have an instance name (or the instance name is mispelled)

    - does not exist in the frame where that code is trying to talk to it

    - is animated into place but is not assigned instance names in every keyframe for it

    - is one of two or more consecutive keyframes of the same objects with no name assigned in the preceding frame(s).

     

    If you go into your Publish Settings Flash section and select the option to Permit debugging, your error message should have a line number following the frame number which will help you isolate which object is involved.

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 13, 2012 8:38 PM   in reply to bogdano.

    It is really hard to read what you just posted.  The first error seems to be indicating the problem is in frame 160, line 1, not frame 1 line 30.  The problemed line is always the first in the error... the rest are just identifying the trail back to what led to encountering that line.

     

    Just as an example, if the following line is indicated as being the problem...

     

    fbkWeDance_btn.addEventListener(MouseEvent.CLICK, clickFbk);

     

    then fbkWeDance_btn does not exist as far as that line sees it.  It's up to you to figure out why... different frame, misspelled name, no name, etc...

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 14, 2012 4:17 AM   in reply to bogdano.

    That is one way to approach it and it is fine to do.  Another would be to use dynamic textfields throughout the site and have the selected language text dynamically written to all the textfields for each page, thus requiring only one set of pages (lots of code).

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points