A Flash Developer Resource Site

Results 1 to 11 of 11

Thread: loop

  1. #1
    Junior Member
    Join Date
    Sep 2004
    Posts
    16

    loop

    i want to attach my 16 variables 16 different numbers between the values 0 to 20 .but i could not set the loop.would u help me.thank u
    Last edited by praxy84; 03-19-2005 at 04:15 AM.

  2. #2
    Senior Member bs_grewal's Avatar
    Join Date
    Dec 2002
    Posts
    548
    have u not checked ur last postings??
    Thanks
    Baljit Singh Grewal
    Click here to email me
    Messengers: baljit@bsgrewal.com

  3. #3
    Junior Member
    Join Date
    Sep 2004
    Posts
    16
    yesh i did thank u for it .it worked.but now i have a different problem

  4. #4
    Senior Member bs_grewal's Avatar
    Join Date
    Dec 2002
    Posts
    548
    what is the problem?
    Thanks
    Baljit Singh Grewal
    Click here to email me
    Messengers: baljit@bsgrewal.com

  5. #5
    Junior Member
    Join Date
    Sep 2004
    Posts
    16
    now i want to attach 16 different number to my 16 variables randomly

  6. #6
    Senior Member bs_grewal's Avatar
    Join Date
    Dec 2002
    Posts
    548
    can u explain me what is ur purpose for it? for what u want to do it?
    Thanks
    Baljit Singh Grewal
    Click here to email me
    Messengers: baljit@bsgrewal.com

  7. #7
    Junior Member
    Join Date
    Sep 2004
    Posts
    16
    okay.i have 16 different movieclips. and i have 16 different spaces for them of which i know the cooredinates.i want them to fill these positions randomly.it is about a game.

  8. #8
    Senior Member bs_grewal's Avatar
    Join Date
    Dec 2002
    Posts
    548
    instead of using vars i would suggest u to use array.

    just copy and paste my following code in the first frame of ur timeline and see the output.

    __________________________________________________ _______
    tilenames = new Array();
    tilenames = ["tile1","tile2","tile3","tile4","tile5","tile6","t ile7","tile8","tile9","tile10","tile11","tile12"," tile13","tile14","tile15","tile16"];

    Array.prototype.shuffle = function() {
    for (ivar=this.length-1; ivar>=0; ivar--) {
    var p = random(ivar);
    var t = this[ivar];
    this[ivar] = this[p];
    this[p] = t;
    }
    };

    tilenames.shuffle();
    for(i=0;i<tilenames.length;i++){
    trace("tile" add i add " = " add tilenames[i])
    }
    __________________________________________________ ____________
    Thanks
    Baljit Singh Grewal
    Click here to email me
    Messengers: baljit@bsgrewal.com

  9. #9
    Senior Member bs_grewal's Avatar
    Join Date
    Dec 2002
    Posts
    548
    sorry
    my last code has an error
    try following
    __________________________________________________ _

    tilenames = new Array();

    tilenames = ["tile1","tile2","tile3","tile4","tile5","tile6","t ile7","tile8","tile9","tile10","tile11","tile12"," tile13","tile14","tile15","tile16"];

    Array.prototype.shuffle = function() {
    for (ivar=this.length-1; ivar>=0; ivar--) {
    var p = random(ivar);
    var t = this[ivar];
    this[ivar] = this[p];
    this[p] = t;
    }
    };

    tilenames.shuffle();
    for(i=0;i<tilenames.length;i++){
    trace("tile" add i add " = " add tilenames[i])
    }
    Thanks
    Baljit Singh Grewal
    Click here to email me
    Messengers: baljit@bsgrewal.com

  10. #10
    Senior Member bs_grewal's Avatar
    Join Date
    Dec 2002
    Posts
    548
    here is the fla file
    Thanks
    Baljit Singh Grewal
    Click here to email me
    Messengers: baljit@bsgrewal.com

  11. #11
    Junior Member
    Join Date
    Sep 2004
    Posts
    16
    sorry for replying too late.i tried ur solution and it worked.thank u. and this another way of doing that.thank u agian good luck



    onClipEvent(load){
    for(z=0;z<17;z++){
    _root["box"+i]=random(16)+1;
    }
    }
    onClipEvent(enterFrame){
    for(i=0;i<17;i++){
    for(j=0;j<i;j++){
    if(_root["box"+j]==_root["box"+i] ){
    _root["box"+i]=random(16)+1;
    continue;
    }
    }
    }
    }

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