You should instead store available types of weapons in the array from where you choose the weapon type. Also, that array should contain int
s, because apparently your cupcakes are spent on fire/action, thus you will have the ammo storage array at your disposal. If you need unlocked array, by all means make another array. (Make sure there's a default weapon, though, or else cake selection function can go into an infinite loop)
var cupcakesAmmo:Array=[0,0,0,0,0,0,0]; // as many as you have types of cupcakes
var cupcakesTypes:Array=[RedCupcake,YellowCupcake,PinkCupcake,GreenCupcake,BlueCupcake,PurpleCupcake,BlackCupcake];
// let's say we have seven cupcakes
var currentCupcake:int; // the selected weapon
function cupcakeChangeButton(e: MouseEvent) {
// first check if we actually have anything to change to
var weHave:int=0; // how many different cupcakes we have
var i:int;
for (i=0;i<cupcakesAmmo.length;i++) if (cupcakesAmmo[i]>0) weHave++;
if (weHave<2) return; // hehe, we either have no cupcakes or just one type of em
// otherwise let's change
do { // we have to do this at least once
currentCupcake++;
if (currentCupcake==cupcakesAmmo.length) currentCupcake=0; // change type
} while (cupcakesAmmo[currentCupcake]==0); // change until we find the type with nonzero ammo
// okay, type selected, let's get proper display
CupcakeNavigationBox.countBox.text = "x" + cupcakesAmmo[currentCupcake];
// see, no switch is needed! Just get the data off your array :)
// TODO change the displayed cupcake too (I don't see where you do this)
}