A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: [RESOLVED] targetting individual dynamic children

  1. #1
    Senior Member
    Join Date
    May 2000
    Posts
    814

    resolved [RESOLVED] targetting individual dynamic children

    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.0;
            
    //var buttonWidth:int=menuItem.menuLabel.width+3;
            
    menuItem.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_OVERmouseOverHandler);
            
    menuItem.addEventListener (MouseEvent.MOUSE_OUTmouseOutHandler);
            
    menuItem.addEventListener (MouseEvent.MOUSE_DOWNmousePressHandler);

            
    menuMC.addChild(menuItem);

            
    //Increment the menu button counter, so we know how many buttons there are
            
    i++;
            
            
        }
        
            
    menuItem.addChild(logoLdr);



  2. #2
    Senior Member
    Join Date
    May 2000
    Posts
    814
    fixed it by adding

    PHP Code:
            if (i==0){

          
    menuItem.addChild(logoLdr);
          } 
    after the line menuMC.addChild(menuItem);

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center