A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: multiple conditions in a "for loop" ?

  1. #1
    Junior Member
    Join Date
    May 2008
    Posts
    19

    multiple conditions in a "for loop" ?

    Can you use multiple conditions in a for loop?

    For example, I am trying to attach images 1-6 to a specific movieclip, and images 7-12 to another and so on.

    So my logic was to do this:

    for (i=1; i<=6; i++) {
    container.attachMovie("thumb"+i,"thumb"+i+"_mc",i) ;
    }

    for (i=1: i>6 && i<13; i++) {
    container2.attachMovie("thumb"+i,"thumb"+i+"_mc",i );
    }

    But it's not working. Ony the top loop works.

    Can someone clarify how it should be done?

    Katie

  2. #2
    Senior Member
    Join Date
    Apr 2002
    Location
    Saginaw, MI
    Posts
    185
    You could just use a single loop, and put the selection logic inside of it. Try a variation of this:

    Code:
    for (i=1; i <= 15; i++) {
    	if (i <= 6) {
    		container1.attachMovie ("thumb" + i, "thumb" + i + "_mc", i);
    	} else if (i <= 12) {
    		container2.attachMovie ("thumb" + i, "thumb" + i + "_mc", i);
    	} else {
    		containerN.attachMovie ("thumb" + i, "thumb" + i + "_mc", i);
    	}
    }
    I am determined to make better mistakes tomorrow.

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