Greetings.
I am going through a really head pain because of an error I am unable to resolve and, after many trials and errors, I came here to look for help.
The game logic is like this.
. The game is a mystery game, which you are in a basement and you have to find a key in order to go out. Once you have it, you go to the next room: the corridor.
. Once in the corridor, you can either go left to the library or right to enter a room.
. The next object (a code) is in a mask in the room. Once you pick it up, you go to the library, open a safe box and pick up a door knob.
. The exit door is in the corridor. You use the door knob to exit.
Now, this is the logic of the inventory.
. The inventory is a movie clip which has 4 frames / states, the first one it's empty, the second shows a key, the third shows the key and a code and the fourth shows the key, code and a door knob.
. You start with an empty inventory.
. I created a function that reads something like this:
function checkInventory()
{
if (keyTaken)
{
inventory.gotoAndStop(2);
}
if (keyTaken && codeTaken)
{
inventory.gotoAndStop(3);
}
if (keyTaken && codeTaken && doorknobTaken)
{
inventory.gotoAndStop(4);
}
}
Simple.
. I checkInventory() when the player picks up an object.
. I checkInventory() everytime I enter a new scene.
. Now, when I am in the basement, and I want to go to the corridor, it works perfectly. The same happens when I go to the library. And even if I go back to the basement.
. But when I enter the room, I receive an error that says:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at KikisEscape_fla::MainTimeline/checkInventory()
at KikisEscape_fla::MainTimeline/frame5()
at flash.display::MovieClip/gotoAndStop()
at KikisEscape_fla::MainTimeline/corridorRightDoorClick()
. I double check everything and there is no way this error has to occur. And it does only in this room.
. Looks like the problem is when I click the right door of the corridor, but it is simply a: gotoAndStop(1, "Room"); The same way is used in the other scenes.
What can this be? What am I missing?
Thanks you for any advice you can share with me!