Post edited 11:50 am – May 5, 2009 by smonte
Post edited 10:05 am – May 11, 2009 by smonte
Post edited 6:33 pm – May 14, 2009 by smonte
Post edited 6:39 pm – May 14, 2009 by smonte
Post edited 6:42 pm – May 14, 2009 by smonte
Hey,
If you want to add individual links to each button you could do something like this.
First add a link attribute to each item (give some URL…)
Then in the createMenu() function add a mouse click listener to each menu item.
//This function creates a single menu (= one vertical menu).
//It returns all the menu items which belong to the created menu.
function createMenu(menu:XML):Array {
//Create an array which contains all the items in this menu
var menuItems:Array = new Array();
//Loop through the items found in the menu
for each (var item:XML in menu.item) {
//Create a new menu item
var menuItem:MenuItem = new MenuItem();
//Set the menuItem to have no mouseChildres
menuItem.mouseChildren = false;
//Set the item text
menuItem.menuText.text = item.toString();
//Add a link variable (the URL where this item should link to)
menuItem.link =
//Add a click listener
menuItem.addEventListener(MouseEvent.CLICK, itemClicked);
//Add the item to the menuArray
menuItems.push(menuItem);
}
}
And then create the function itemClicked() and navigate to the specified URL.
function itemClicked(e:Event):void {
//Get the item that dispatched the event
var item:MenuItem = e.target as MenuItem;
//Navigate to the URL that's assigned to the menu item
var urlRequest:URLRequest = new URLRequest(item.link);
navigateToURL(urlRequest);
}
Hope that gets you started!
Regards,
smonte