PDA

View Full Version : [AS3] Problem With Game


omare14
05-30-2011, 10:48 PM
I'm making a game and I'm almost done. There's one problem though. I set it up so that when the player hits the enemy, it jumps to the next frame in the timeline which is the game over screen. But I get an error every time it jumps to the game over frame. it also kind of messes up the last frame.

TypeError: Error #1009: Cannot access a property or method of a null object reference.
at El_fla::MainTimeline/scroll()
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at El_fla::MainTimeline/movement()
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at El_fla::MainTimeline/stopmove()

I think it has to do with the functions but how do I get rid of this output error?

neogrant
05-30-2011, 10:54 PM
I'm learning AS3 so I could be wrong when I say this, but have you opened up the actions panel (f9) and selected the game over screen and put:

stop();

omare14
05-30-2011, 11:11 PM
No, I wish it were that simple, but I already tried that. I think it's because the functions keep running but theres no instance for the function to run anything so it brings that up. I don't know how to fix it though.

omare14
05-31-2011, 01:33 AM
I have 2 problems that I need to solve so I can finish this project. 1, I need to figure out why I get this error when I have a gotoAndStop on the timeline

TypeError: Error #1009: Cannot access a property or method of a null object reference.
at El_fla::MainTimeline/scroll()
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at El_fla::MainTimeline/movement()
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at El_fla::MainTimeline/stopmove()

I think it has to do with these event listeners

stage.addEventListener(KeyboardEvent.KEY_DOWN,scro ll);
stage.addEventListener(KeyboardEvent.KEY_DOWN,move ment);
stage.addEventListener(KeyboardEvent.KEY_UP,stopmo ve);

My second problem is that I want to make two difficulties for my game. The way that I did this for my game in AS2 was to just copy the code and frames since all of the code was on its own instance and mc. Now that there are variables and functions, how would I be able to make another difficulty that only changes a few values and variables without having to change each individual function and variable.
If a document class is the way to fix this then please let me know how on my other post called "Classes"
I'm attaching the .fla and the .as files.

El-Sherif_Project 3_FINAL=fla
Main=as