FP.choose just chooses a random element from an array. For it to work with your hierarchy you could add everything in the hierarchy (or a subset of it) to an array then choose from that. For example;
/**
Function to pick a Loot-derived item from all items in the game, with a matching
chestLevel/itemLevel. For example, chestLevel 5 only ever picks Loot with itemLevel 5.
*/
public function pickItem(chestLevel: int): Loot
{
var allItems: Array = new Array; //array to contain all items
var i: int; //avoid multiple definition warnings
//now add all of each type (or folder, or whatever) to the all items list
for(i = 0; i < weapons.Length; i++) { allItems.push(weapons[i]); }
for(i = 0; i < armor.Length; i++) { allItems.push(armor[i]); }
for(i = 0; i < potions.Length; i++) { allItems.push(potions[i]); }
//now do some fun stuff to select possible items from the all items array
var possibleItems: Array = new Array;
for(i = 0; i < allItems.Length; i++)
{
if(allItems[i] is Loot) //only allow Loot
{
//make sure the Loot class has an 'itemLevel' public variable or getter
if((allItems[i] as Loot).itemLevel == chestLevel)
{
//this item level is compatible with this chest. Allow the item!
possibleItems.push(allItems[i]);
}
}
//finally, choose the item from the possible items list!
if(possibleItems.Length > 0)
{
return (FP.choose(possibleItems) as Loot);
}
return null; //there were no possible items. Handle this!
}
}
Key thing is to make sure all Lootable items are derived from Loot and set their itemLevel variable appropriately.