Inventory Check ---> checking for certain items

Okay I have the following Inventory code.

This adds it your inventory slots

[AS]
currentslotnum = 1;
stop();
function addToslot(item) {
if (!item.found) {
item._x = eval(“itemSlot”+currentslotnum)._x;
item._y = eval(“itemSlot”+currentslotnum)._y;
item.found = true;
currentslotnum++;
}
}
[/AS]

so that’s good…

And this allows you to pick it up

[AS]
onClipEvent (enterFrame) {
if (_root.character.hitTest(this)) {
_root.addToslot(this);
}
}
[/AS]

Great so that all works perfectly. But Say If want to check if a user has a certain item if so…such an such happens…etc. But I can’t figure out how I would do this with an If statement. No matter what I can’t get it to work( That is what you’d use right?). Can anyone tell me the best way to do a “check” for this type of thing. Thanks in advance :).

How would I do that? I mean how could I use an array to check whether the object has been picked up yet or not? I don’t see how :h:

WHen the character hittest the item, push the item to the array.
Then later, run a for loop inside the array to check if some item exists.

Err…I’m very confused…could you give me an example maybe?

For example:

inventory = new Array();//inventory array to store the items collected
Array.prototype.find = function(item) {//prototype to search for a string inside an array
	var found = false;
	for (var i = 0; i<this.length; i++) {
		if (this* == item) {
			found = true;
		}
	}
	return found;
};
function addToslot(item) {//function to add item to the inventory
	if (!inventory.find(item)) {//if the item isnt already in the inventory
		inventory.push(item);//add the item to the inventory
	}
}
stop();

And on your item:

onClipEvent (enterFrame) {
        if (_root.character.hitTest(this)) {
                _root.addToslot(this);
        }
}