Hello, I am making a menu in which i want to switch ON the selected submenu and button, and OFF the previous submenu and button, could anybody please tell me what is wrong with my code:
// Attach events to menu buttons
body_mc.menu_mc.addEventListener(MouseEvent.CLICK, updateSub);
// Declaring the menu elements to update
var previousBtn:MovieClip;
var currentBtn:MovieClip;
var previousSub:MovieClip;
var currentSub:MovieClip;
// Update current and reset previous
function updateSub(event:MouseEvent):void {
// Only if currentBtn has a value already
if (currentBtn) {
previousBtn=currentBtn;
previousSub=currentSub;
previousBtn.prevFrame();
}
// Update current value
currentBtn=event.target.parent;
currentSub=event.target.parent.parent;
currentBtn.nextFrame();
// Prevent animation of the same movieclip
if (currentSub!=previousSub) {
previousSub.gotoAndPlay("off");
currentSub.gotoAndStop("selected");
}
}
What am i missing here, i know previousBtn is not identifying currentBtn before currentBtn is gaining a value, but how is it happening anyway and ignoring the if condition?
Thanks