# Creating Inventory for Flash games

**URL:** <https://forum.kirupa.com/t/creating-inventory-for-flash-games/7145>\
**Category:** flash\
**Created:** [October 24, 2002, 3:35pm UTC](https://forum.kirupa.com/t/creating-inventory-for-flash-games/7145 "2002-10-24T15:35:34Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![FLATLINE\_\_](https://avatars.discourse-cdn.com/v4/letter/f/f07891/32.png) [@FLATLINE\_\_](https://forum.kirupa.com/u/FLATLINE__)\
**Post date:** [October 24, 2002, 3:35pm UTC](https://forum.kirupa.com/t/creating-inventory-for-flash-games/7145/1 "2002-10-24T15:35:34Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [October 24, 2002, 3:45pm UTC](https://forum.kirupa.com/t/creating-inventory-for-flash-games/7145/2 "2002-10-24T15:45:47Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [October 24, 2002, 4:18pm UTC](https://forum.kirupa.com/t/creating-inventory-for-flash-games/7145/3 "2002-10-24T16:18:28Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [October 25, 2002, 1:01pm UTC](https://forum.kirupa.com/t/creating-inventory-for-flash-games/7145/4 "2002-10-25T13:01:45Z")

</div>

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

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
