Creating Inventory for Flash games

Can anyone suggest me how to create an inventory system for a flash game? Ya know, those stuff that like lets say there’s a box on the screen, you click on it and it is added to your inventory, then you can select it from your inventory screen and use it for stuff.

Any ideas?

try this, this code on the first frame of the main timeline, on the stage:a button with instancename “inventbutton”:

inventory = new Array();
trace(inventory);
inventbutton.onPress = function()
{
currentItem = “shoe”;
attachItem(currentItem);
}
function attachItem(itemName)
{
inventory.push(itemName);
trace(inventory);
}

Steve

thanks but how will you USE items in the inventory and how will you graphicly display them in slots?

I assume you are trying to create some game like diablo?
so, you’ll need healthpotions :slight_smile:

to use an item you could use this code, where healthpotion is the name of the button:

health = 50;
healthpotion.onPress = function()
{
currentItem = “healthpotion”;
useItem(currentItem);
}
function useItem(itemName)
{
health += 50;
_root.healthindicator.healthbar._xscale = (health/100 * 100);
}

to display the items in an inventory list, you’ll need the inventory array, for every item in that array you have to create a button in the inventory movieclip

Steve