00:00
00:00
Newgrounds Background Image Theme

Vaittus just joined the crew!

We need you on the team, too.

Support Newgrounds and get tons of perks for just $2.99!

Create a Free Account and then..

Become a Supporter!

Error 1009, the bane of my code.

473 Views | 5 Replies
New Topic Respond to this Topic

Error 1009, the bane of my code. 2014-08-22 16:33:57


So, I'm making a small function whereby when I click on a movieclip it's opacity depletes. I've got it to work, but I get flooded with the dreaded error 1009, could someone help me edit my code to remove the error, or should I just ignore it.

Code:

stop();
Button_lvl_1.addEventListener(MouseEvent.CLICK, MouseClicks)
function MouseClicks (event:Event):void {
Button_lvl_1.alpha -= 0.01
}

Response to Error 1009, the bane of my code. 2014-08-22 16:39:54


At 8/22/14 04:33 PM, GrahamNG wrote: So, I'm making a small function whereby when I click on a movieclip it's opacity depletes. I've got it to work, but I get flooded with the dreaded error 1009, could someone help me edit my code to remove the error, or should I just ignore it.

Code:

stop();
Button_lvl_1.addEventListener(MouseEvent.CLICK, MouseClicks)
function MouseClicks (event:Event):void {
Button_lvl_1.alpha -= 0.01
}

You should never ignore an error. Look at what the error is telling you: "Cannot access a property or method of a null object reference." Assuming the error occurs in the code you posted, it's telling you that something is null that you're trying to access. The only thing you're trying to access is Button_lv1; therefore, that button is null i.e. it does not exist. The button might exist on the screen, but it's not connected to the button variable you have in your code. Or you set the variable to null at some point.

Response to Error 1009, the bane of my code. 2014-08-22 17:29:07


The 1009 error is the bane of all new programmer. It basically means "You said this object was suppose to be here, but it's not"

It's most likely the object "Button_lvl_1", you can probably confirm this by putting trace(Button_lvl_1) on the first line.
We can't really help because you're probably programming in the Adobe Flash IDE. This means a lot depends on the placement of items in frames and MovieClips.

Consider switching to a programming focused IDE like FlashDevelop, where 99% of your coding issues will be because of your code, rather than the placement of items on frames.


If ya have something to say, PM me. I have a lot of time to spare.

Also never PM egg82.

BBS Signature

Response to Error 1009, the bane of my code. 2014-08-23 08:05:58


You should never ignore an error. Look at what the error is telling you: "Cannot access a property or method of a null object reference." Assuming the error occurs in the code you posted, it's telling you that something is null that you're trying to access. The only thing you're trying to access is Button_lv1; therefore, that button is null i.e. it does not exist. The button might exist on the screen, but it's not connected to the button variable you have in your code. Or you set the variable to null at some point.

When I trace the button_lvl_1, in the output panel I get 'Object Movieclip' followed by error 1009. So, 'alpha' is of undefined property? How should I access it then?

Response to Error 1009, the bane of my code. 2014-08-23 08:39:20


At 8/23/14 08:05 AM, GrahamNG wrote: When I trace the button_lvl_1, in the output panel I get 'Object Movieclip' followed by error 1009.

Did you try stepping through your program with the debugger?
Please do so.

So, 'alpha' is of undefined property? How should I access it then?

alpha being undefined should not cause the error
I don't think it's undefined either, but try this yourself by tracing it

Response to Error 1009, the bane of my code. 2014-08-23 08:59:09


At 8/23/14 08:39 AM, milchreis wrote:
At 8/23/14 08:05 AM, GrahamNG wrote: When I trace the button_lvl_1, in the output panel I get 'Object Movieclip' followed by error 1009.
Did you try stepping through your program with the debugger?
Please do so.

So, 'alpha' is of undefined property? How should I access it then?
alpha being undefined should not cause the error
I don't think it's undefined either, but try this yourself by tracing it

I just used debugger for the first time, and I've subsenquently fixed my code, one of my buttons was using an incorrect way of identification (xxx .alpha = xxx, over xxx.addEventListener) causing my entire code to mess up. I've fixed it. Thanks.