I have 16 buttons on the stage layed out in a grid of 4*4. When the user clicks a button it is brought to the top depth and then expands to the size of 4 buttons. The issue is I have a for loop that adds the functionality to the button. The button has a onRelease method attached to it and nested inside is a onPress action for the expanded state. I need to delete the onPress method if another button is pressed to start the button proccess over but am having a hard time. Here is my code.
function gotoURL(movieNum) {
getURL("javascript:flashURL("+movieNum+");");
}
// ----
for (i=0; i<=16; i++) {
this["b"+i].onRelease = function() {
// -- bring selected button to the top deptht
_root.x += 2;
this.swapDepths(_root.x);
// -- defines last selected button and then delete it
var lastBtn:MovieClip;
this._parent.lastBtn.gotoAndPlay(11);
trace("Button Event One");
this.gotoAndPlay(2);
this._parent.lastBtn = this;
updateAfterEvent();
delete this._parent.lastBtn.onPress;
// -- If the user clicks the on state then it goes to some URL
this.onPress = function() {
//_root.gotoURL(i);
trace("Button Event two");
updateAfterEvent();
};
};
}
an additional issue is the nested onPress function is not in scope of the var i which is outputing as undefined.