I want to add a logo to my dynamic menu tabs, the code below adds the logoLdr to the very last tab, but i want to add logoLdr to the first tab generated?
How do i target individual tabs in this loop?
PHP Code:
function createMyMenu():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 xml.link) {
menuItem = new MenuItem();
menuItem.id = i;
//If the text is longer than the textfield, autosize so that the text is
//treated as left-justified text
menuItem.menuLabel.autoSize = TextFieldAutoSize.RIGHT;
//Insert the menu text (link.@pgTitle reads the link's "pgTitle" attribute)
menuItem.menuLabel.text = link.@pgTitle;
menuItem.y = 0;
//var buttonWidth:int=menuItem.menuLabel.width+3;
menuItem.x = i*(menuWidth+menuGap)+menuOrigin;
//Make the button look like a button (hand cursor)
menuItem.buttonMode = true;
menuItem.mouseChildren = false;
//Add event handlers (used for animating the buttons)
menuItem.addEventListener (MouseEvent.MOUSE_OVER, mouseOverHandler);
menuItem.addEventListener (MouseEvent.MOUSE_OUT, mouseOutHandler);
menuItem.addEventListener (MouseEvent.MOUSE_DOWN, mousePressHandler);
menuMC.addChild(menuItem);
//Increment the menu button counter, so we know how many buttons there are
i++;
}
menuItem.addChild(logoLdr);
}