Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 06-01-2004, 01:52 PM   #1
rkdresden
Registered User
 
Join Date: Jun 2004
Posts: 7
Default need help with unique numbers

Hi,

I am a newbie to actionscript (programming in general) and I am trying to accomplish the following but don't know how to do it.


I have an array which starts out with 3 unique numbers between 1 and 30.

For example :

myArray = new Array();
myArray[0] = 13;
myArray[1] = 22;
myArray[2] = 29;



OK, a bit further down on my movie timeline, I will need to add 3 additional unique numbers to this array which are also between 1 and 30, but cannot be duplicates of the first three. In other words, when all is said and done, the total 6 numbers have to be unique numbers between 1 and 30.


Any suggestions?


Thanks you!
RK
rkdresden is offline   Reply With Quote
Old 06-01-2004, 02:51 PM   #2
prt1
FlashScape
 
Join Date: Mar 2004
Posts: 139
Default

Try the following idea, not sure if syntax is correct.
newnum = 20;
test = 0;
for (x=0; x<myArray.getLength(); x++) {
if (newnum == myArray[x]) {
test = 1;
}
}
If (test==0) {
myArray[3] = newnum;
} else {

// go back to start with another newnum
prt1 is offline   Reply With Quote
Old 06-02-2004, 10:10 AM   #3
rkdresden
Registered User
 
Join Date: Jun 2004
Posts: 7
Default

Thank you prt1!

I used your code and looped through it for all 3 new numbers.

It seems to be working fine.
Thanks again!
rkdresden is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump


All times are GMT. The time now is 01:21 AM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.