Skip to main content
Participating Frequently
November 9, 2010
Question

Error #1009: Help needed

  • November 9, 2010
  • 1 reply
  • 2144 views

Hello everyone,

I'm looking for some help with an error I'm getting:

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

Now, I know approximately what it means, I just can't find where exactly the problem is or how to fix it.

I must warn tho, my code is a bit chaotic, had a rough start and now I'm just trying to finish before the deadline, and with my time left I'm gonna clean up the code.

I think it's best if I send the entire flash project in a zip so if you are willing to help just let me know how to reach you

Thanks in advance.
Davey

This topic has been closed for replies.

1 reply

Inspiring
November 9, 2010

Enable debugging in publish settings and Flash will display line number that is at fault.

Participating Frequently
November 9, 2010

Done that, got a few solved but a few others that I have no clue about

Getting this error now: (sorry for the dutch error but it's the same as I said in english above)

TypeError: Error #1009: Kan geen eigenschap of methode benaderen via een verwijzing naar een object dat null is.
at Main/addClasses()
at Main/menuKeuzeNext()

These are the 2 classes that seem to generate the error:

menuKeuzeNext() -> mostly just a input control class

ActionScript Code:
private function menuKeuzeNext(event:MouseEvent):void
        {
            hideAlerts();
            naam = MovieClip(inputMenu).naamInput1.text;
            bedragString = MovieClip(inputMenu).bedragInput1.text;
            bedrag = int(bedragString);
           
            //alle invoer alerts terug op onzichtbaar zetten voor als men bv naam verbeterd heeft maar bedrag nog steeds incorrect is, anders blijft alert van naam ook staan.
           
           
            //invoercontrole
            if(naam == "")
            {
                showAlert("leeg", "naam")
            } else if(naam.length > 30)
            {
                showAlert("te lang", "naam");
            }
            if(bedrag == 0)
            {
                showAlert("Bedrag is leeg", "bedrag");
            } else if(bedrag < 2.5)
            {
                showAlert("Bedrag moet minstens 2,5 euro zijn", "bedrag");
            }
            if(naam.length < 30 && bedrag > 2.5 && naam !="")
            {
                gotoAndStop(2);
                inputMenu.visible = false;
                newImageMC.visible = false;
                addClasses();
            }
        }

addClasses() -> adds classes that I need to be able to draw and erase in frame 2

ActionScript Code:
private function addClasses():void
        {
            var eraserClass:Eraser;
            var spraycanClass:Spraycan;
           
            eraserClass.setDrawBoard(drawBoard);
            eraserClass.setButton(eraser);
            //eraserClass.setActive(active);
            eraserClass.setDrawSize(drawSize);
            eraserClass = new Eraser();
            trace("if");
               
            spraycanClass.setDrawBoard(drawBoard);
            spraycanClass.setButton(spraycan);
            spraycanClass.setDrawSize(drawSize);
            spraycanClass.setColorsMC(colors);
            spraycanClass.setSizePanel(sizePanel);
            spraycanClass = new Spraycan();
        }

drawBoard is a movieclip on my stage, and yes the instance name is correctly filled in, same for eraser, drawSize, colors, spraycan and sizePanel

Rui Silva
Inspiring
November 9, 2010

I'd suspect any of those objects which you are trying to access properties on. The error is quite common for uninitialized object types and I see a few variables in your code that haven't been initialized ( eraserClass and spraycanClass). Yet I don't know if they're stage Movieclips or not. Seeing the whole project would surely help in identifying the problem.

Cheers,

Rui