Push and pop

hi, i was wondering if i could get a bit of help. i have a flash application where the player move clip can collide with 4 objects which will then trail it, the only trouble is i only want one object to trail at any one time…

so far i have tried creating an array, where a collected (trailing) object is “pushed” when collected then popped off the array when its dropped (when it collides with another movie clip). now im trying to put in a if statement where only if the array is empty another item can be collected, but i don’t know where i’m going wrong, or even if this is the best way to do it

var inventory = new Array();

if(inventory.length == 0)

{
pickup object
inventory.push(objectA);
}
if(object dropped)

{
pop off object // so inventor array is now empty

}

}

i can post the segment of code if this is unclear

thanks for looking