This is what I think the easiest way:
- add instance var to the boxes to indicate its position
- pick boxes at position of your choice
- pick random(boxes.pickedcount) nth box
- destroy box
Demo: https://www.dropbox.com/s/fmusqnu88io24il/boxes.capx?dl=1
There another way that I was thinking without instance variable, but I think it will require significantly longer code (using array, sorting, etc).
Note that in the way you are creating the boxes, the 4 corner boxes are actually double (2 boxes on top of each other), each belong to one side.