I answered that already, although I didn't notice until now that you are using 
the random() global function which was depreciated with Flash 4.  While it may 
server your purpose, use Math.random() as I demonstrated previously.

but you're also not providing any information on how the value for 
totalSetsNLayout is determined, which random relies on.

Jason Merrill   |   E-Learning Solutions   |  icfconsulting.com










>>-----Original Message-----
>>From: [EMAIL PROTECTED] [mailto:flashcoders-
>>[EMAIL PROTECTED] On Behalf Of Corban Baxter
>>Sent: Wednesday, February 01, 2006 4:56 PM
>>To: Flashcoders mailing list
>>Subject: RE: [Flashcoders] understanding the for loop
>>
>>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,lay
>>out4_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:flashcoders-
>>[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: flashcoders@chattyfig.figleaf.com
>>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
>>Flashcoders@chattyfig.figleaf.com
>>http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>>
>>_______________________________________________
>>Flashcoders mailing list
>>Flashcoders@chattyfig.figleaf.com
>>http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>>_______________________________________________
>>Flashcoders mailing list
>>Flashcoders@chattyfig.figleaf.com
>>http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
NOTICE:
This message is for the designated recipient only and may contain privileged or 
confidential information. If you have received it in error, please notify the 
sender immediately and delete the original. Any other use of this e-mail by you 
is prohibited.
_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to