as3 mouseChildren=true does not hold the name of the button created
for(var l:int=0; l<anXML.length(); l++){
aButton=new btn_secondTier();
aLocation.addChild(aButton);
//var aButtonDefaults:ButtonDefaults=new ButtonDefaults(aButton);
aButton.y=l*24;
aButton.name=anXML[l].attribute("id");
aButton.title_txt.text=anXML[l].theTitle;
aButton.addEventListener(MouseEvent.ROLL_OVER,onDropOver);
aButton.addEventListener(MouseEvent.ROLL_OUT,onDropOut);
aButton.addEventListener(MouseEvent.CLICK,onClick);
aButton.mouseChildren=true;
for(var k:int=0; k< anXML[l].thirdMenu.length(); k++){
bButton=new btn_thirdTier();
aButton.thirdContainer_mc.addChild(bButton);
bButton.addEventListener(MouseEvent.ROLL_OVER,onMouseOver);
bButton.addEventListener(MouseEvent.ROLL_OUT,onMouseOut);
bButton.buttonMode = true;
bButton.useHandCursor = true;
bButton.y=k*24;
bButton.name=anXML[l].thirdMenu[k].attribute("id");
//bButton.addEventListener(MouseEvent.CLICK,onClick);
aButton.thirdContainer_mc.visible=false;
bButton.title_txt.text=anXML[l].thirdMenu[k].theTitle;
bButton.mouseChildren=false;
}
// PREVENTS THE THIRD NAV FROM THE PRESENTATION BUTTON FROM OVERLAPPING THE EDGE OF THE SCREEN
if(aLocation==main.mainNav_mc.btn_2.secondaryContainer_mc){
aButton.thirdContainer_mc.x=201;
}
// FRAME AROUND TERTIARY BUTTONS
aButton.thirdContainer_mc.thirdNavBG_mc.height=(aButton.thirdContainer_mc.height);
var thirdBGHeight:Number=(aButton.thirdContainer_mc.thirdNavBG_mc.height)+2;
aButton.thirdContainer_mc.thirdNavBG_mc.height=thirdBGHeight;
aButton.thirdContainer_mc.thirdNavBG_mc.width=202;
aButton.thirdContainer_mc.thirdNavBG_mc.x=-1;
aButton.thirdContainer_mc.thirdNavBG_mc.y=-1;
}
Currently building a dynamic menu system, with 3 levels of navigation. Currently when mouse children is set to 'true' it doesn't want to remember the name of the menu item created.
it spits out, 'instance263' or whatever the number is when I trace it out with my onClick event.
With mouseChildren set to 'false' my 3rd tier of navigation ceases to work.
The Goal here is to have the menu items retain an instance name so I can relate back to them and set active states for the current active module.
UPDATE:
Here is where the problem arises
private function onClick(e:MouseEvent):void{
var myString=e.target.name;
var aList:Array = myString.split("_");
trace(myString+" gfgfgfg "+argh[0].name);
main.video_controller.nsStream.pause();
main.video_controller.nsStream.close();
main.btn_continue.visible=true;
main.btn_previous.visible=true;
if(e.target.name==xmlData.menu[aList[0]].secondMenu[aList[1]].thirdMenu[aList[2]].attribute("id")){
main.removeActivity();
loadToolBox(xmlData.menu[aList[0]].secondMenu[aList[1]].thirdMenu[aList[2]]);
main.loadModule(xmlData.menu[aList[0]].secondMenu[aList[1]].thirdMenu[aList[2]]);
menu1ID=aList[0];
menu2ID=aList[1];
menu3ID=aList[2];
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// } }
this is the trace that is gfiving me problems.
trace(myString+" gfgfgfg "+argh[0].name);
myString is tracing (instance263) or whatever.
so how come e.target does not trace me my 开发者_如何转开发inst ance name?
In a MouseEvent, remember that the target
property refers to the display object that initially dispatched the event. If your button contains graphics and whatnot, target
probably refers to one of the button's child display objects - the lowest-level thing that actually got clicked.
You probably want to use e.currentTarget
instead. This points to the object that is currently receiving the event as it bubbles through the display list, which will be the button object where you put the listener.
If you're not clear on how event bubbling works, this won't make very much sense. Try this article, for example.
精彩评论