-
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.
-
Senior Member
have u not checked ur last postings??
-
yesh i did thank u for it .it worked.but now i have a different problem
-
Senior Member
-
now i want to attach 16 different number to my 16 variables randomly
-
Senior Member
can u explain me what is ur purpose for it? for what u want to do it?
-
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.
-
Senior Member
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])
}
__________________________________________________ ____________
-
Senior Member
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])
}
-
Senior Member
-
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|