-
1. Re: TypeError: Error #1009: Cannot access a property or method of a null object reference.
kglad Jul 21, 2009 11:01 AM (in response to scasey1982)1 person found this helpfulclick file/publish settings/flash and tick "permit debugging" and retest to pinpoint your error. the frame and line number that's causing the error will be displayed.
-
2. Re: TypeError: Error #1009: Cannot access a property or method of a null object reference.
scasey1982 Jul 21, 2009 11:24 AM (in response to kglad)I have pinpointed the problem being the function that I am trying to call, but I still do not know why it is giving me a problem. I am assuming that something has not been initiated on stage from what I have read, but I have no clue how to fix it. Thanks.
viewCottage_btn.addEventListener(MouseEvent.CLICK, goCottage);
function goCottage(evtObj:MouseEvent)
{
trace("test")
} -
3. Re: TypeError: Error #1009: Cannot access a property or method of a null object reference.
scasey1982 Jul 21, 2009 11:59 AM (in response to kglad)kglad, I believe you have helped billygoatkareoke out before with the exact same problem I am having now(http://forums.adobe.com/message/2021469#2021469). I think my buttons weren't instantiated when my test first played and the code executed.
You were able to solve his problem by looking at/and adjusting his code, unfortunately the code was not posted and the file link on the post is no more so I can not reference it. Is there any way you can help me out?
Thanks for your help so far.
-
4. Re: TypeError: Error #1009: Cannot access a property or method of a null object reference.
kglad Jul 21, 2009 12:00 PM (in response to scasey1982)a function won't give a null object reference error. the line above your function could be causing the error but it should be obvious which line is causing the error because the lines are numbered. which line is referenced in the error message and copy and paste the exact error message.
-
5. Re: TypeError: Error #1009: Cannot access a property or method of a null object reference.
scasey1982 Jul 21, 2009 12:17 PM (in response to kglad)You're right,
viewCottage_btn.addEventListener(MouseEvent.CLICK, goCottage);
I found a similar post to mine(http://forums.adobe.com/message/2021469#2021469), you were able to help him, but unfortunately it was through file swapping so I could not reference the solution.
Do you think you can help me out?
-
6. Re: TypeError: Error #1009: Cannot access a property or method of a null object reference.
kglad Jul 21, 2009 12:37 PM (in response to scasey1982)if
viewCottage_btn.addEventListener(MouseEvent.CLICK, goCottage);
is the line referenced in the error message, viewCottage_btn doesn't exist when that error message occurs.
-
7. Re: TypeError: Error #1009: Cannot access a property or method of a null object reference.
scasey1982 Jul 21, 2009 12:44 PM (in response to kglad)I am begining to understand. How can I go about making it exist when it is reference?
-
8. Re: TypeError: Error #1009: Cannot access a property or method of a null object reference.
kglad Jul 21, 2009 12:52 PM (in response to scasey1982)that depends how you create that instance.
if it's done on the timeline, then you should have that code attached to the first frame where that object first appears and never remove that object for as long as it's needed.
-
9. Re: TypeError: Error #1009: Cannot access a property or method of a null object reference.
scasey1982 Jul 21, 2009 1:08 PM (in response to kglad)I have two scenes, each with one frame. The first scene calls the preloader code, and the second scene has the main content where the problem code is located. That is where the object first appears and that is where the code is but I am still getting an error.
I am confused because I do not reference it anywhere else. here is my code if that sheds any light on the subject.
-
10. Re: TypeError: Error #1009: Cannot access a property or method of a null object reference.
kglad Jul 21, 2009 2:18 PM (in response to scasey1982)use a trace() statement to confirm that the error occurs as the playhead enters the frame that contains your button for the first time. if so, you have a typo either in the code or the properties panel. use copy and paste to make sure they match.
-
11. Re: TypeError: Error #1009: Cannot access a property or method of a null object reference.
scasey1982 Jul 21, 2009 2:37 PM (in response to kglad)I traced "fff" at the begining of scene two and it appeared before the error occurred. The instance name of the button and the reference I made are the same. but I am still getting errors for every button that I call.
fff
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at cottage_website_fla::MainTimeline/frame2()[cottage_website_fla.MainTimeline::frame2:10]
at flash.display::MovieClip/nextFrame()
at cottage_website_fla::MainTimeline/updatePreloader()[cottage_website_fla.MainTimeline::fra me1:8]
-
12. Re: TypeError: Error #1009: Cannot access a property or method of a null object reference.
kglad Jul 21, 2009 5:09 PM (in response to scasey1982)is the code that causes the error message and the button in the same frame? if so, you have a typo.
-
13. Re: TypeError: Error #1009: Cannot access a property or method of a null object reference.
scasey1982 Jul 22, 2009 5:44 AM (in response to kglad)Ok, I finally started a new flash file and used more than one frame. Everything seems to be working now. Thanks for your help!
-
14. Re: TypeError: Error #1009: Cannot access a property or method of a null object reference.
kglad Jul 22, 2009 9:16 AM (in response to scasey1982)you're welcome.
-
15. Re: TypeError: Error #1009: Cannot access a property or method of a null object reference.
David Causy May 11, 2011 11:08 AM (in response to kglad)Hi kglad,
I recently suffered a similar problem and reading your advice here helped me get it working again. Just wanted to let you know your helping us all and we appriciate it
THANK YOU!!!
p.s. you're a genious