Hi, assistance greatly appreciated
I am attempting to build navigation dynamically, an XML file is built from a php script calling a MySQL data base, the ActionScript interprets the XML file. The function that builds the navigation is shown below. The trace call within buildMainNav (trace("name is " + mainNav_mc.name) shows the name being set correctly. A MouseEvent.CLICK is assigned to each button and this is where the script falls down. When I try to access the name of the button clicked from with in the navigate() function. In the navigate() function the trace(e.target.name) call returns the instance name such as insance14 or instance10.
Any help greatly appreciated.
Kind regards
Patrick
private function buildMainNav(e:Event):void {
if (xml) {
var i:Number = 0;
for each(var navNode:XML in xml..navNode) {
mainNav_mc = new mc_mainNav();
mainNav_mc.name = navNode.labelName.toString();
if(!getChildByName(navNode.labelName.toString())) {
addChild(mainNav_mc);
trace("name is " + mainNav_mc.name);
mainNav_mc.x = 10;
mainNav_mc.y = i * 100;
mainNav_mc.addEventListener(MouseEvent.MOUSE_OVER, setMouseOver);
mainNav_mc.addEventListener(MouseEvent.MOUSE_OUT, flyIn_leftMain);
mainNav_mc.addEventListener(MouseEvent.CLICK, navigate);
} else {
var inBut:DisplayObject = getChildByName(navNode.labelName.toString());
new Tween(inBut, "x", Strong.easeIn, -200, 10, 0.5, true);
//trace(inBut.name);
}
mainNav_mc.mainNav_txt.text = (navNode.labelName);
mainNav_mc.buttonMode = true;
//var getBtn:Object = getChildByName(mainNav_mc);
//trace(getBtn.name);
i++;
}//end for each
}//end if xml
}//end build main nav
private function setMouseOver(e:MouseEvent):void {
trace("over");
}
private function navigate(e:MouseEvent):void {
trace(e.target.name);
}