John G
03-31-2008, 07:00 PM
Basically what happens, a button is clicked, and this function is launched.
It creates a new series of buttons to click (seperate from the first button) (and the hit spots aren't added yet) depending on variables in a 2d array. Which works fine.
The problem is the next time a button is clicked I need to get rid of the buttons this function made the last time so it can make a new series of buttons. I thought to do this with removeMovieClip() to just get rid of the new button's parent movieclip (subButtonContainer) but no dice.
Is there a better way to get rid of the old dynamically created clips before making the new ones?
function makeSubButtons(indexKeeper, picWidth, picHeight, picX, picY) {
subButtonContainer.removeMovieClip();
var subButtonContainer:MovieClip = this.createEmptyMovieClip("subButtonContainer", this.getNextHighestDepth());
subButtonContainer.attachMovie("subButton", "subButton_", 1);
for (var i = 0; i<imageArray[indexKeeper].length; i++) {
subButtonContainer["subButton_"].duplicateMovieClip("subButton_"+i, subButtonContainer.getNextHighestDepth());
subButtonContainer["subButton_"+i].subButtonText.text = (i+1);
subButtonContainer["subButton_"+i]._x = 98+(20*i);
subButtonContainer["subButton_"+i]._y = (picY+picHeight);
}
}
It creates a new series of buttons to click (seperate from the first button) (and the hit spots aren't added yet) depending on variables in a 2d array. Which works fine.
The problem is the next time a button is clicked I need to get rid of the buttons this function made the last time so it can make a new series of buttons. I thought to do this with removeMovieClip() to just get rid of the new button's parent movieclip (subButtonContainer) but no dice.
Is there a better way to get rid of the old dynamically created clips before making the new ones?
function makeSubButtons(indexKeeper, picWidth, picHeight, picX, picY) {
subButtonContainer.removeMovieClip();
var subButtonContainer:MovieClip = this.createEmptyMovieClip("subButtonContainer", this.getNextHighestDepth());
subButtonContainer.attachMovie("subButton", "subButton_", 1);
for (var i = 0; i<imageArray[indexKeeper].length; i++) {
subButtonContainer["subButton_"].duplicateMovieClip("subButton_"+i, subButtonContainer.getNextHighestDepth());
subButtonContainer["subButton_"+i].subButtonText.text = (i+1);
subButtonContainer["subButton_"+i]._x = 98+(20*i);
subButtonContainer["subButton_"+i]._y = (picY+picHeight);
}
}