Ok so I found this tutorial for building an XML menu but what it fails to do explain how to give each nav an instance name so I can bring in content or whatever. Can anyone please tell me what I need to do so that I can add an event listener to each movieclip. Thanks in advance if you can help. I am also looking for more in depth xml tutorials or books that will teach how to search nodes (I know how to search with a trace but not how to attach it to a button), or any other advanced techniques using xml.
Thanks in advanced
in the for each statement, add this below the instantiation:
menuItem = [COLOR=#000000]**new**[/COLOR] MenuItem[COLOR=#66CC66]([/COLOR][COLOR=#66CC66])[/COLOR];
// ADD THIS LINE
menuItem.name = link.@name + "_mc";
menuItem.menuLabel.text = [[COLOR=#000066]link[/COLOR]](http://www.php.net/link).@name;
that should work, names wil be
Home_mc
Works_mc
About_mc
Contact_mc
[quote=creatify;2335230]in the for each statement, add this below the instantiation:
ActionScript Code:
[LEFT]menuItem = <font [COLOR=#0000FF]color[/COLOR]=[COLOR=#FF0000]"#000000"[/COLOR]><b>new</b></font> MenuItem<font [COLOR=#0000FF]color[/COLOR]=[COLOR=#FF0000]"#66CC66"[/COLOR]>[COLOR=#000000]([/COLOR]</font><font [COLOR=#0000FF]color[/COLOR]=[COLOR=#FF0000]"#66CC66"[/COLOR]>[COLOR=#000000])[/COLOR]</font>;
[COLOR=#808080]// ADD THIS LINE[/COLOR]
menuItem.[COLOR=#0000FF]name[/COLOR] = link.@[COLOR=#0000FF]name[/COLOR] + [COLOR=#FF0000]"_mc"[/COLOR];
menuItem.[COLOR=#000080]menuLabel[/COLOR].[COLOR=#0000FF]text[/COLOR] = <a href=[COLOR=#FF0000]“http://www.php.net/link”[/COLOR] [COLOR=#0000FF]target[/COLOR]=[COLOR=#FF0000]"_blank"[/COLOR]><font [COLOR=#0000FF]color[/COLOR]=[COLOR=#FF0000]"#000066"[/COLOR]>link</font></a>.@[COLOR=#0000FF]name[/COLOR];
[/LEFT]
that should work, names wil be
Home_mc
Works_mc
About_mc
Contact_mc[/quote]
Thank you very much
This is what I did with that function since I am not trying to link external pages but I want to link it to other mc’s etc
function createMenu():void {
//This will be used to represent a menu item
var menuItem:MenuItem;
//Counter
var i:uint = 0;
//Loop through the links found in the XML file
for each (var link:XML in settingsXML.links..link) {
menuItem = new MenuItem();
//Insert the menu text (link.@name reads the link's "name" attribute)
menuItem.menuLabel.text = link;
menuItem.name = link;
//If the text is longer than the textfield, autosize so that the text is treated as left-justified
menuItem.menuLabel.autoSize = TextFieldAutoSize.LEFT;
//Insert the menu button to stage
menuItem.x = 20;
menuItem.y = 20 + i * 25;
//Make the button look like a button (hand cursor)
menuItem.buttonMode = true;
menuItem.mouseChildren = false;
//Add event handlers
//menuItem.addEventListener (MouseEvent.CLICK, mouseClickHandler);
addChild(menuItem);
//Increment the menu button counter, so we know how many buttons there are
i++;
}
}
So now my instance names are Home, About, etc… but I cant add an event listener because flash says its an undefined property so how do I get around this.