I’m having issues with the following menu. I’ve been adapting a script from kirupa into actionscript 3.
When I get to the last level of the menu it won’t link properly. It always takes the last url of the bunch as the url for all links in that branch of the tree.
Can anyone help me get it to link properly? A zip with the fla and the xml can be found at the following link.
http://www.jdviz.com/projects/xmlmenu.zip
Thanks,
There’s a problem with the closures at the end of the code. The current button is not identified properly.
if (node_xml.childNodes[i].nodeName != "resource") { //cleared the code for clarity... } else { curr_item.arrow.visible = false; curr_item.addEventListener(MouseEvent.MOUSE_DOWN, function(e:MouseEvent):void { trace(curr_item.urlLink); }); }change the above to:
var currentButton:MenuItem_mc = new MenuItem_mc(); function mouseOverHandler(e:MouseEvent ):void { currentButton = e.currentTarget as MenuItem_mc; currentButton.addEventListener( MouseEvent.CLICK , clickHandler ); } function clickHandler(e:MouseEvent):void { var btn:MenuItem_mc = event.currentTarget as MenuItem_mc; trace( btn.urlLink ); } if (node_xml.childNodes[i].nodeName != "resource") { //cleared the code for clarity... } else { curr_item.arrow.visible = false; curr_item.addEventListener(MouseEvent.MOUSE_DOWN, mouseOverHandler ); }