Rereading code

Ive got a little problem here. You can see im duplicating some movieClips, in a for loop. They have some XML values, but thats not important.

When i click one of the movieClips ive duplicated, ive set it to add one to the “length” variable. But i somehow need it to run though the code from start, when i press that button. And if its possible, to delete all the duplicates it made before. Thanks in advance.
[AS]length = 2
for (i = 0; i<length; i++){
duplicateMovieClip(button, “button”+i, i);
setButton = _root[“button”+i];
if (answerCheck == ‘true’){
setButton.onRelease = function(){
length++;
}
}
}[/AS]