Okay, I have a weird problem and I’m not sure if it is possible to do what I’m trying to do.
I have a navigation with 4 dropdown menus (with instance names mainNav1_mc, mainNav2_mc, etc). Inside those dropdown menus are buttons (with instance names nav1_1, nav1_2, etc…). The button behavior is controlled by a custom class called BasicButton that extends MovieClip. All of this works great.
The problem comes when I try to match the target of an event listener to the object it was added to… here’s the code (inside the Navigation class file):
this.mainNav1_mc.nav1_1.addEventListener(MouseEvent.CLICK, selectNav1_1);
trace(mainNav1_mc.nav1_1);
private function selectNav1_1(evt:MouseEvent):void {
trace(evt.target);
if (evt.target == this.mainNav1_mc.nav1_1) {
trace(“they are the same!”);
}
}
THIS DOESN"T WORK! The first trace returns [object Subnav0_5]. Awesome. The second trace returns a generic [object MovieClip] instead of [object Subnav0_5] and the third trace never fires!
Am I missing something? I’ve tried casting the target as a BasicButton, but it didn’t work. Anyone able to help with this?
BTW, in case you’re wondering why I would EVER want to do this, I am creating an extensible drop-down menu system which is created on the stage and then initialized in the code with a series of arrays. The code is generalized, so I will not need to touch the functionality, no matter how many menus there are or how many buttons are in each menu. I simply need to add them to the arrays.
Thanks,
Andy