Line 6: ReferenceError: x is not defined


#1

Hi, again. Making a maze game. The code I used for the cursor is:

function update (){
this.x = mouseX
this.y = mouse
}

if(this.hitTest(wall.png)) {
this.gotoAndStop(2)
}
if(this.hitTest(wall2.png)) {
this.gotoAndStop(2)
}
if(this.hitTest(wall3.png)) {
this.gotoAndStop(2)
}
if(this.hitTest(i.png)) {
this.gotoAndStop(3)
}

Somehow got this line 6: ReferenceError: wall.png is not defined.
Help please.


#3

Where did you define wall.png? Is there an object in the scene with that name?


#4

Yes. Since that error, I modified the project.


#5

So how’s it going? Need any more help?


#6

Hi there!

I seem to have missed this post - sorry about that! Please let me know if you need any other help.


#7

Yup. How do I stop this error?


#8

Javascript probably doesn’t like the name “wall.png”. It implies there is an object called “wall” which contains something called “png”.

Try naming the image something else, and use that name in your code!


#9

Thanks. Also converted images to movie clips at that time.


#10

I got rid of png and it will not want to listen