A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: nested in a for loop

  1. #1
    flash animator guy
    Join Date
    Oct 2006
    Location
    Daly City
    Posts
    219

    nested in a for loop

    Can any one tell me how to do this with a nested MC in a for loop? I've tried
    "tab_MC"+i+"tabBttn_MC"
    "tab_MC"+i+".tabBttn_MC"
    tab_MC+i+.tabBttn_MC
    tab_MC+i+tabBttn_MC

    None of the seem to work.

    var tabButtonsArray:Array = new Array("tab_mc1", "tab_mc2", "tab_mc3", "tab_mc4", "tab_mc5");

    function bringToFront(event:MouseEvent):void {
    trace("good");
    }

    for (var i:Number=1; i<6; i++) {
    tab_MC+i+tabBttn_MC.addEventListener(MouseEvent.RO LL_OVER, bringToFront);
    }

  2. #2
    :
    Join Date
    Dec 2002
    Posts
    3,518
    Code:
    function bringToFront(e:MouseEvent):void {
    	trace("good "+e.currentTarget+" "+e.currentTarget.parent.name+" "+e.currentTarget.name);
    }
    
    for (var j:uint = 1; j < 6; j++) {
    	this["tab_mc"+j].tabBttn_MC.addEventListener(MouseEvent.ROLL_OVER,bringToFront);
    }
    or
    Code:
    var tabButtonsArray:Array=new Array(tab_mc1,tab_mc2,tab_mc3,tab_mc4,tab_mc5);
    
    function bringToFront(e:MouseEvent):void {
    	trace("good "+e.currentTarget+" "+e.currentTarget.name);
    }
    
    for (var i:* in tabButtonsArray) {
    	tabButtonsArray[i].addEventListener(MouseEvent.ROLL_OVER,bringToFront);
    }

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