Skip to main content
Keenix
Participant
June 29, 2015
Answered

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

  • June 29, 2015
  • 2 replies
  • 20422 views

I need a little help. I'm making a game, and everything works fine except for the fact that I have 2 errors, one that doesn't bother me as I can still use the button, but the other one won't let me use the button.

Error:

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

    at Untitled_2_fla::MainTimeline/frame2()[Untitled_2_fla.MainTimeline::frame2:207]

    at flash.display::MovieClip/gotoAndStop()

    at Untitled_2_fla::MainTimeline/PlayBtn()[Untitled_2_fla.MainTimeline::frame1:13]

//Magyx Placement

RedAtk.addEventListener(MouseEvent.CLICK, RedAttack);

function RedAttack(Event:MouseEvent):void

{

    gotoAndStop(19)

}

That's where Frane2:207 is, I don't see anything wrong with it, considering all my other ones are the same

nextBlueAtk.addEventListener(MouseEvent.CLICK, NWA);

function NWA(Event:MouseEvent):void

{

    gotoAndStop(23)

}

nextGreyAtk.addEventListener(MouseEvent.CLICK, NGA);

function NGA(Event:MouseEvent):void

{

    gotoAndStop(27)

}

nextGreenAtk.addEventListener(MouseEvent.CLICK, NGRA);

function NGRA(Event:MouseEvent):void

{

    gotoAndStop(31)

}

I get no errors for those ones.

And frame1:13?

function PlayBtn(event:MouseEvent):void

{

    gotoAndStop(2)

}

Someone please help, I want to continue working on this game!

This topic has been closed for replies.
Correct answer robdillon

When Flash tells you that there is a null object reference, it means that an object that you are referring to in a function is not available at that point in the movie. Usually this is a problem with the object not being in a particular frame. Make sure that the object, the button, is actually in the frame where the function reference is located.

2 replies

Known Participant
July 11, 2015

Have same problem. When the game is ended and then when i click the home button is says:

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

  at KKK25_fla::MainTimeline/qwe()[KKK25_fla.MainTimeline::frame4:50]

can anyone help me?

robdillon
Participating Frequently
July 11, 2015

It's the same problem. I'm guessing that you have several things listed in that mouse event function. You might need to change the order in which the actions are called. Can you show the code in that function?

June 5, 2016

Have some problem, my flash file  : Dropbox - flash.rar

please help

robdillon
robdillonCorrect answer
Participating Frequently
June 29, 2015

When Flash tells you that there is a null object reference, it means that an object that you are referring to in a function is not available at that point in the movie. Usually this is a problem with the object not being in a particular frame. Make sure that the object, the button, is actually in the frame where the function reference is located.

Keenix
KeenixAuthor
Participant
June 29, 2015

Oh my gosh, I'm so dumb! I've only known AS3 for a two days and pretend I'm a master at it. I was coding on the wrong frame! Lol thank you so much. Time to fix my other games with this error.