How should I refer to these specific arrays?
Hello,
I'm making a shopping cart which has a checkout area where there are "slots" that are filled with a rectangle describing the items within it. Each slot is filled via an addChild using an array that ensures each slot is placed precicely below the previous slot. Here's the code for that (cartslot is the name of the movieclip):
Code:
function sendDVDToCheckout(evt:MouseEvent):void {
var slot:cartslot = new cartslot();
shoppingCart.addChild(slot);
var slotPos:Number = ((checkoutSlotsArray.length) * slot.height);
checkoutSlotsArray.push(slot);
itemCounter++;
slot.name = String(itemCounter);
slot.x = 0;
slot.y = slotPos;
slot.cartText.text = "Indoor Shred DVD";
for (var i:int = 0; i < checkoutSlotsArray.length; i++) {
checkoutSlotsArray[i].closeSlot.buttonMode = true;
checkoutSlotsArray[i].closeSlot.useHandCursor = true;
checkoutSlotsArray[i].closeSlot.addEventListener(MouseEvent.CLICK, clearSlot);
}
}
On each cartslot mc is a delete button that the user can click to remove that item from the checkout, hence the last few lines of code (the delete button has been named "closeSlot").
What I need to know is how to get each slot positioned below the deleted slot to move up and fill the gap that the deleted one caused. I know I need to tell it something like "for each movieclip that is higher in the array than the deleted one, move them up by mc.height and then delete the selected one from the array" but I'm not sure how to go about this.
It seems to me like this should be quite an easy task but I'm really not sure how to determine which one the user has clicked, and how to refer to all of the ones higher in the array than it.
I'm completely new to arrays so specific code help rather than cryptic clues is greatly appreciated :)
Thanks.