dcsimg
A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: [RESOLVED] help with loops

  1. #1
    AS3 N00B
    Join Date
    Feb 2002
    Location
    NYC
    Posts
    308

    resolved [RESOLVED] help with loops

    How do i turn the following into a loop:

    Code:
    	month1.htmlText = seriesInput.chart_form.six_month1;
    	month2.htmlText = seriesInput.chart_form.six_month2;
    	month3.htmlText = seriesInput.chart_form.six_month3;
    	month4.htmlText = seriesInput.chart_form.six_month4;
    	month5.htmlText = seriesInput.chart_form.six_month5;
    	month6.htmlText = seriesInput.chart_form.six_month6;
    I tried this to no avail:

    Code:
    	for (var i:Number = 1; i < 7; i++){
    		this["month"+i].htmlText = seriesInput.chart_form.six_month[i];
    	}
    -Neo

  2. #2
    Bearded (M|G)od MyFriendIsATaco's Avatar
    Join Date
    Dec 2002
    Location
    Awesomeville.
    Posts
    3,046
    Almost:
    Code:
    for (var i:Number = 1; i < 7; i++){
    		this["month"+i].htmlText = seriesInput.chart_form["six_month"+i];
    	}

  3. #3
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    There is no property called six_month on chart_form. You could use the same dynamic property syntax you used for the months.
    Code:
    this["month"+i].htmlText = seriesInput.chart_form["six_month"+i];
    But, instead of using naming schemes, you should put the months and the six_months(?) into arrays so you can access them conveniently.

    If they were in arrays, you could do this:
    Code:
    	for (var i:Number = 1; i < 7; i++){
    		months[i].htmlText = seriesInput.chart_form.six_months[i];
    	}

  4. #4
    AS3 N00B
    Join Date
    Feb 2002
    Location
    NYC
    Posts
    308
    thank you guys for the insanely quick response!
    -Neo

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