Here is a better idea of what I need I think I posted the code off a little...

[code]
imgArray = new Array();
        for(i=0; i<=imagesToGrab; i++){
                
                randomSet = random(totalSetsNLayout) + 1; //totalSetsNLayout = 4
                //shouldn't i get a random number between 1-4?
                trace("randomSet: " + randomSet);
                img = "layout" + layoutNum + "_set" + randomSet + "_img" + i;
                imgArray.push(img);
        }
        trace("imgArray: " + imgArray);
[/code]

[output]
layoutNum: 4
totalSetsNLayout: 3
imagesToGrab: 6
randomSet: 1 //needs to be random
randomSet: 1 //needs to be random
randomSet: 1 //needs to be random
randomSet: 1 //needs to be random
randomSet: 1 //needs to be random
randomSet: 1 //needs to be random
randomSet: 1 //needs to be random
imgArray = 
[layout4_set1_img0,layout4_set1_img1,layout4_set1_img2,layout4_set1_img3,layout4_set1_img4,layout4_set1_img5,layout4_set1_img6]
[/output]

so why is the randomSet never random?


Corban Baxter      |      rich media designer      |      www.funimation.com


-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Adrian Lynch
Sent: Wednesday, February 01, 2006 3:44 PM
To: Flashcoders mailing list
Subject: RE: [Flashcoders] understanding the for loop

You're not incrementing imagesToGrab anywhere.

for (...) {
        .....
        imagesToGrab++;
}

Ade

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf Of Corban
Baxter
Sent: 01 February 2006 21:29
To: [email protected]
Subject: [Flashcoders] understanding the for loop


Ok guys I am working with this for loop to help me grab random images. My
problem is it seems like the for loop won't reset and random var each time
it runs. Below is my code...

[code]
for(i=0; i<=imagesToGrab; i++){
        randomSet = random(totalSetsNLayout) + 1;
        img = random(imagesToGrab)+1;
        img = "layout" + layoutNum + "_set" + randomSet + "_img" + i;
        imgArray.push(img);
}
[/code]

imgArray = [
layout5_set1_img0,
layout5_set1_img1,
layout5_set1_img2,
layout5_set1_img3,
layout5_set1_img4,
layout5_set1_img5,
layout5_set1_img6,
layout5_set1_img7,
layout5_set1_img8,
layout5_set1_img9,
layout5_set1_img10,
layout5_set1_img11]

as you can see my problem is that it doesn't change my set randomly at all?
Any ideas why this happens?

Corban Baxter      |      rich media designer      |      www.funimation.com


_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to