Removing spheres

What happens when gameStatus is removing? Here it is another case to add to our big switch statement in onEnterFrm function:

case "removing" :
for (i=0; i<chainArray.length; i++) {
with (balance) {
getChildByName(chainArray[i]).alpha-=0.2;
if (getChildByName(chainArray[i]).alpha<0) {
removeChild(getChildByName(chainArray[i]));
var parts:Array=chainArray[i].split("_");
gameArray[parts[0]][parts[1]]=0;
gameStatus="adjusting";
}
}
}
break;

The meaning of this code should be quite clear: the for loop scans for all elements in chainArray array, which are the names of the spheres to remove.

Every child of balance DisplayObject with the name corresponding to each element in chainArray array will have its alpha property decreased by 0.2, ...

Get Flash Game Development by Example now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.