Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    Flash




Random Array Of Numbers - No Repeats



hi, I want to create a random array of 20 numbers (1-20) where every number is different.

I have the following so far:

item = 0;
number_limit = 20;

function insertRandomNumber(){
random_numbers[item] = random(number_limit)+1;
item++;
}

this function is called 20 times on the timeline, but my problem is I can't figure out a way of having it so that numbers aren't repeated in the array. Any help would be appreciated.



FlashKit > Flash Help > Flash ActionScript
Posted on: 07-08-2003, 05:39 AM


View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread

Random Numbers With No Repeats
I am trying to make some code that will generate random numbers without any repeats...

What I actually need to do is call up random movie clips into my movie, but never get the same one twice.

I'm a bit new to all this so I need some pretty basic help!

Hope someone can help!

Random Numbers No Repeats
Hi, need to make a string of 15 random numbers which will be used to present symbols in a 5x3 grid.

The string is made of 5 substrings which contain 3 random numbers inside from the range 1-15 - the same number cannot be allowed in the same substring

EXAMPLE = (5,10,1)(15,6,10)(3,14,4)(11,1,8)(9,7,12)

Basically i need a function which generates non repeating random numbers to a designated amount and range.

I can then do this 5 times and add each together.

Any help appretiated.

Generate Random Numbers W/o Repeats
I need help doing some simple actionscript to generate a random number between 1 and 20 and not repeat the numbers until all of them have been processed.

Example... I want to put 20 pictures on the screen, one at a time, in 20 different locations (the pictures are all different) until the whole screen is filled up. I know how to do all the coordinates, etc. Just need help generating the numbers.

Any help would be appreciated.

Generating Random Numbers With No Repeats
I'm a bit of a beginner still and I'm trying to make some code that will generate randon numbers between say 10 and 30, but never give the same number twice..

Then I want call up a movie clip of the same name as the random number generated... Basically I need to call up movie clips randomly without any repeats.


Can anyoune help please?

Random Numbers Without Sequential Repeats
Hi, all, I'm looking to generate random numbers in actionscript in order to load corresponding images from an array, but I need for there to be no sequential repeats.

My current workaround is as follows:


ActionScript Code:
function update(evt:TimerEvent):void {
    var rand = randomNumber(low,high);
        if (previousImage == rand) {
            rand += 1;
            if (rand > high) {
                rand = low;
            }
        }
    var previousImage = rand;
}

//this portion is not my work

function randomNumber(low:Number=NaN, high:Number=NaN):Number {
    var low:Number = low;
    var high:Number = high;

    if (isNaN(low)) {
        throw new Error("low must be defined");
    }
    if (isNaN(high)) {
        throw new Error("high must be defined");
    }

    return Math.round(Math.random() * high - low) + low;
}

As you can see, my workaround says that if the same number was picked twice in a row, advance to the next array key. However, this skews the probability of "random," as that next image now has double the chance of being picked.

Is there a better way to get Flash to pick a random number, excluding the previous pick?

The closest lead I've found is something called "random_shuffle()" for C++ (mentioned here). I don't suppose AS3.0 has an equivalent?

[CS3] AS2: How To Make A Random Jpg Array The Repeats
Hi )
I apologize for starting a new thread but my last question has a new face.
I have an Array Randomly loading images on to the stage, there is a 'splice'
so no 2 images repeat. the problem is - once the images all get 'deleted' there are
no more images the array can pull. I want the images to be recreated in the array.
If I remove the 'splice' I can load as many images as I want however some load twice
or more before the batch is complete.

This is the code I have (with the splice) :

Code:
var images:Array = new Array();
for (var i:Number = 0; i < 29; i++) {
images.push("image" + i + ".jpg");
}

images[0]="image0.jpg";
images[1]="image1.jpg";
images[2]="image2.jpg";
images[3]="image3.jpg";
images[4]="image4.jpg";
images[5]="image5.jpg";
images[6]="image6.jpg";
images[7]="image7.jpg";
images[8]="image8.jpg";
images[9]="image9.jpg";
images[10]="image10.jpg";
images[11]="image11.jpg";
images[12]="image12.jpg";
images[13]="image13.jpg";
images[14]="image14.jpg";
images[15]="image15.jpg";
images[16]="image16.jpg";
images[17]="image17.jpg";
images[18]="image18.jpg";
images[19]="image19.jpg";
images[20]="image20.jpg";
images[21]="image21.jpg";
images[22]="image22.jpg";
images[23]="image23.jpg";
images[24]="image24.jpg";
images[25]="image25.jpg";
images[26]="image26.jpg";
images[27]="image27.jpg";
images[28]="image28.jpg";

var picture:MovieClip = this.createEmptyMovieClip("picture",1);
picture._x = -167;
picture._y = 86;

btnRand.onPress = function() {
var num:Number = Math.floor(Math.random() * images.length);
picture.loadMovie(images[num]);
images.splice(num, 1);
};


Is there a way to do this ?

any help at all is much appreciated

Array Sorting - Random With No Back-to-back Repeats
I need help with a complex array sorting method, and I apologize if this concept has already been addressed in the forums. Part of my problem is that I don't know how to concisely describe it, so I can't do an effective forum search.

I start with an input array of strings that will be of varying length and may contain repeat values. I need to randomly sort the array and return an array with the same values, but it should try to distribute values evenly and avoid back-to-back repeats if possible.

(Sorry, that's the confusing part. Hopefully the examples will explain better. Colors are not important, just added to aid visual)

**************************************************
Example 1 (Random order, avoiding back-to-back repeats):
**************************************************

If the input array is
["dog", "dog", "dog", "dog", "cat", "cat", "cat", "bird", "bird", "fish"]

I need to output
["dog", "cat", "dog", "cat", "bird", "dog", "cat", "bird", "dog", "fish"]

but the order also needs to be randomized, sometimes giving me
["fish", "dog", "bird", "dog", "cat", "bird", "cat", "dog", "cat", "dog"]

OR
["bird", "cat", "bird", "dog", "cat", "dog", "fish", "dog", "cat", "dog"]

ETC.

************************************************** ***********
Example 2 (Distribute as evenly as possible if back-to-back repeats are unavoidable):
************************************************** ***********

If the input array is
["dog", "dog", "dog", "dog", "dog", "cat", "cat"]

I need to output
["dog", "dog", "cat", "dog", "dog", "cat", "dog"]

but also randomized, sometimes giving
["dog", "cat", "dog", "dog", "cat", "dog", "dog"]

OR
["dog", "dog", "cat", "dog", "cat", "dog", "dog"]

ETC.

Any help with this would be appreciated. If this type of sorting has a name, let me know so I can look it up.

Random Numbers From 0 - 9 In Array
What should I do so I end up with an array of random numbers like

[2, 6, 4, 9, 0, 3, 7, 8, 1, 5]
[3, 5, 8, 1, 9, 0, 6, 7, 2, 4]

I'm thinking like starting with an ordered array
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]

randomly pick one by one out
[0, 1, 2, 3, 4, 5, 6, 8, 9] -> [7]
[0, 1, 3, 4, 5, 6, 8, 9] -> [7, 2]
[0, 1, 3, 4, 5, 6, 8] -> [7, 2, 9]
[0, 1, 3, 5, 6, 8] -> [7, 2, 9, 4]

Until I end up with something randomly sequenced.

How can that be done? Or is there a better way?

Help With Array And Random Numbers
Hi, I wanna be able to populate an array of 25 element with a random number between 0 and 4.

But I cant have more than 5 elements of the array with the same generated number.

Example, I need an array like this:

0 2 0 1 4
3 1 0 2 2
4 0 4 3 1
4 1 0 2 3
3 1 2 4 3

5 element with 0
5 element with 1
5 element with 2
5 element with 3
5 element with 4

Wich is the easiest way ?

Random Numbers From 0-9 In Array
What should I do so I end up with an array of random numbers like

[2, 6, 4, 9, 0, 3, 7, 8, 1, 5]
[3, 5, 8, 1, 9, 0, 6, 7, 2, 4]

I'm thinking like starting with an ordered array
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]

randomly pick one by one out
[0, 1, 2, 3, 4, 5, 6, 8, 9] -> [7]
[0, 1, 3, 4, 5, 6, 8, 9] -> [7, 2]
[0, 1, 3, 4, 5, 6, 8] -> [7, 2, 9]
[0, 1, 3, 5, 6, 8] -> [7, 2, 9, 4]

Until I end up with something randomly sequenced.

How can that be done? Or is there a better way?

Random Numbers From 0-9 In Array
What should I do so I end up with an array of random numbers like

[2, 6, 4, 9, 0, 3, 7, 8, 1, 5]
[3, 5, 8, 1, 9, 0, 6, 7, 2, 4]

I'm thinking like starting with an ordered array
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]

randomly pick one by one out
[0, 1, 2, 3, 4, 5, 6, 8, 9] -> [7]
[0, 1, 3, 4, 5, 6, 8, 9] -> [7, 2]
[0, 1, 3, 4, 5, 6, 8] -> [7, 2, 9]
[0, 1, 3, 5, 6, 8] -> [7, 2, 9, 4]

Until I end up with something randomly sequenced.

How can that be done? Or is there a better way?

Placing Random Numbers Into An Array
Hi!

I am building a quiz type piece where I have 7 frames, but I only want 5 of those frames to show up each time a user comes to the site.

I've written psuedo code for myself in an attempt to understand what the actionscript will need to do.

"Take 7 numbers and choose 5 of those numbers randomly (the numbers can not repeat). Place them into an array in the order they are chosen. Play each number in their order in the array. After all 5 numbers have been played, go to frame 8"

ok, so now, if my psuedo code is correct, I need to translate it to actionscript:

code:
numbers = [1,2,3,4,5,6,7];
randomNumber = numbers[Math.floor(Math.random() *6)];

Ok, I can tell I already have a problem here. This only gives me 1 number. I need 5, and 5 numbers that don't repeat. So...I guess I'll leave this as my first question, before I worry about the rest.

Does anyone have a suggestion for me?

Thanks!

Array With Unique Random Numbers
Hi,
I'm trying to come up with a function that will populate an array with 4 unique random numbers. I'm stuck on pushing unique numbers, the attached code creates the array, but sometimes there are duplicate numbers. I've tried a for staement inside the for stement to test for duplicates but get lost. Is there an easy way to do this? Thanks.











Attach Code

var myAreaArray:Array = new Array();

function randPush(min:Number, max:Number):Number {
var randomNum:Number = Math.floor(Math.random()*(max-min+1))+min;
return randomNum;
}

function fillArray():Void {
for (var i:Number = 0; i<=3; i++) {//repeat 4 times
var arrayn:Number = randPush(1, 8);//The random number and range. The range in this case 1 thru 8
var pushed:Object = myAreaArray.push(arrayn);
}
}

fillArray();
trace(myAreaArray); //might return something like 7,4,1,7

How Can I Generate An Array Of *exclusive* Random Numbers?
I have been trying to write some code that will produce a list of *exclusive* random numbers between 1 –10.

What seemed very easy has actually taxed me to death!

I have started by setting up a standard “for” loop to push random numbers (generated by Math.random() ) into an array. I then set up another “for loop” within the first to go through all the indexes in the holding array & if the number at that index was not = to the random number generated, push that number onto the end of the array to give an array of exclusive numbers. Problem I have, apart from the fact that the above is about as much good as a chocolate teapot, is how do I know how many times to loop the initial for loop – I can’t tell how long it will take to generate a list of totally exclusive random numbers. If I tell it to loop 10 times it might just come up with 5 exclusive numbers – 3,8,6,4,4,5,3,3,9,1 – only 8,6,5,9,1 all the rest are duplicated.

Any ideas or better ways to achieve this?

Random With No Repeats
I am trying to make a randomizer, but the usual problem occurs with Flash's own "random" command; it is not very random.

How do I make a randomizer which doesn't repeat the same number again and again?

The script I tried is:

randomstory = random(4);

if (randomstory == 0) {
gotoAndPlay("Scene 1", 1);}
etc. etc. etc.

Thanks in advance,
:: Serviator

Random.. With & Without Repeats.. Help?
Okay guys.. your help is needed! I need to make a clay-shooting type game, but instead of normal targets that you are shooting you are instead shooting rhyming words. The aim is to shoot 2 words that rhyme and there are 10 pairs that rhyme in the game (and ofcourse lots of ones that don't!).

Now this is my problem... I need to randomize it. I need to go to a random frame (which will have a movieclip of 2 words to shoot), however if the player gets the pair wrong .. i need it to go and play another random frame BUT it can go back to that frame at any time (i.e it still can be selected randomly). However.. if the player gets the pair right I want to go to another random frame BUT the correctly completed frame can no longer be accessed (no longer randomly selected).

Does this make sense?

I'm straining my brain but learning heaps in the process Any help would be appreciated very much!

Random Slideshow - No Repeats
Hi People,

I am new to actionscript, but I am fast realising I need to do some serious study to get the hang of all this! I found this slideshow source at www.whatdoiknow.org, and it works perfectly, except that when the slides are set in random (not sequential) they repeat one or two before all the images in the array are shown. Is it possible to make it so that all the images are shown once before there are any repeats?
I would be very grateful for any help you guys can offer! I have attached the fla.
Here is the code:
code:
// **************************
// Crossfading slide show
// Author: Todd Dominey
// http://whatdoiknow.org
// http://domineydesign.com
// **************************
// set random # variables - each must be 0 for first 'while' loop below
var randomNum = 0;
var randomNumLast = 0;
// parent container
var container_mc = this.createEmptyMovieClip("container", 0);
// movie clip containers
container_mc.createEmptyMovieClip("loader1_mc", 2);
container_mc.createEmptyMovieClip("loader2_mc", 1);
// preload watcher
this.createEmptyMovieClip("watcher_mc", 100);
// load xml
images_xml = new XML();
images_xml.ignoreWhite = true;
images_xml.onLoad = parse;
images_xml.load("images.xml");
function parse(success) {
if (success) {
imageArray = new Array();
var root = this.firstChild;
_global.numPause = Number(this.firstChild.attributes.timer*1000);
_global.order = this.firstChild.attributes.order;
_global.looping = this.firstChild.attributes.looping;
_global.fadetime = Number(this.firstChild.attributes.fadetime);
_global.xpos = Number(this.firstChild.attributes.xpos);
_global.ypos = Number(this.firstChild.attributes.ypos);
var imageNode = root.lastChild;
var s = 0;
while (imageNode.nodeName != null) {
imageData = new Object();
imageData.path = imageNode.attributes.path;
imageArray[s] = imageData;
imageNode = imageNode.previousSibling;
s++;
}
// place parent container
container_mc._x = _global.xpos;
container_mc._y = _global.ypos;
// parse array
imageArray.reverse();
imageGen(imageArray);
} else {
trace("problem");
}
}
// depth swapping
function swapPlace(clip, num) {
eval(clip).swapDepths(eval("container_mc.loader"+n um+"_mc"));
}
function loadImages(data, num) {
if (i == undefined || i == 2) {
i = 2;
createLoader(i, data, num);
i = 1;
} else if (i == 1) {
createLoader(i, data, num);
i = 2;
}
}
function createLoader(i, data, num) {
thisLoader = eval("container_mc.loader"+i+"_mc");
thisLoader._alpha = 0;
thisLoader.loadMovie(data[num].path);
watcher_mc.onEnterFrame = function() {
var picLoaded = thisLoader.getBytesLoaded();
var picBytes = thisLoader.getBytesTotal();
if (isNaN(picBytes) || picBytes<4) {
return;
}
if (picLoaded/picBytes>=1) {
swapPlace("container_mc.loader2_mc", 1);
thisLoader.alpha(_global.fadeTime, 100);
timerInterval = setInterval(imageGen, _global.numPause, data);
delete this.onEnterFrame;
}
};
}
function imageGen(data) {
// random, or sequential?
if (_global.order == "random") {
// choose random # between 0 and total number of images
while (randomNum == randomNumLast) {
randomNum = Math.floor(Math.random()*data.length);
trace(randomNum);
}
loadImages(data, randomNum);
randomNumLast = randomNum;
} else if (_global.order == "random") {
// start at 0, increment to total number of images, then drop back to zero when done
if (p == undefined || p == data.length && _global.looping == "yes") {
p = 0;
} else {
break;
}
loadImages(data, p);
p++;
} else {
trace("order attribute in xml isn't correct - must specify either 'random' or 'sequential'");
}
clearInterval(timerInterval);
}
stop();

Play A Random .swf With No Repeats
Hello all,

I have looked all over for help in doing this so any help would be much appreciated.

I have a collection of .swfs, say 20 (made in swish) that only have text. They are only 50 frames long so they are very small files.

What I would like to do is to have a parent movie that chooses one of these .swfs at random, play it, then pick another .swf at random play it, then another etc....

In addition, each .swf must be played before anyone is repeated. They can't be placed in a psudo-random order on the stage as the order must changed each time a visitor visits the page.

Thanks for your help!!!

Function For Random With No Repeats?
Hello, I'd like to have a random number generator that, once it chooses a number, deletes it from the pool of possibilities (it's for a photo gallery that shuffles images from an array)...either that or it keeps repeating the function until it gets a number that hasn't been used.

Any help would be greatly appreciated! Thank you!

Random Frames But No Repeats
gotoAndStop(random(_totalframes)+1);

+1 because there are no frame 0.

this works but sometimes there are repeats how do i make sure that every time I load this , unique frames will be displayed without repeats?

Raskolnikov

Removing Repeats From An Array
I am creating an array of randomly generated numbers, these numbers are coorespond to a question that I then serve to the user. I want to prevent duplicating the questions and thought I had the answer with the following code. It doesn't work tho. Can someone kindly point me in the right direction? I'm using flash mx profossional 2004.

nRand = randRange2(0, 49);
_global.aTempExercise11.push(nRand);
//trace("what in the aTempExercise9 "+_global.aTempExercise9);
for (var t = 0; t<_global.aTempExercise11.length; t++) {
if (_global.aTempExercise11.length>2) {
if (_global.aTempExercise11[t] == _global.aTempExercise11[(t-1)]) {
trace("FOUND A MATCH @"+t+" is "+_global.aTempExercise11[t]);
_global.aTempExercise11.pop();

nRand = randRange2(0, 49);
}
}

}
if (_global.aTempExercise11.length>49) {
_global.aTempExercise11 = new Array();
}

Thank you,

[F8] Random Attach Movie W/o Repeats
I've written the following:


PHP Code:




stop();
createEmptyMovieClip("container", this.getNextHighestDepth());
var images:Array = ["loadin0", "loadin1", "loadin2", "loadin3"];
container.attachMovie(images[random(4)], "images", getNextHighestDepth);
function wait() {
    play();
    clearInterval(timer);
}
timer = setInterval(wait, 5000);






...to randomly attach movies to my container over a specified time, but what I can't figure out is how to script it so it doesn't repeat images.

Does anyone have an idea how I can modify my code to accomplish such a thing?

Thanks in advance for your ideas!

Function For Random Number With No Repeats?
Hello, I'd like to have a random number generator that, once it chooses a number, deletes it from the pool of possibilities (it's for a photo gallery that shuffles images from an array)...either that or it keeps repeating the function until it gets a number that hasn't been used.

Any help would be greatly appreciated! Thank you!

Easy Random Frame Selection (no Repeats)
I have searched for the past hour on this topic and still have not gotton the answer I need. I have a movie. It has 18 frames. I would like the user to click on a button and when they do, be taken to a random frame within these 18. When they click again, another random frame will appear. No frame can be repeated, and when all the frames have been used, then I need the user to be sent to the 19th frame. Using what I learned in this forum, I have set up an array in the first frame of the movie:

code: Mytrans = new Array(1,2,3,4,5,6,7,8,9);

The button has the following:

code:
on (release) {
num = Math.floor(Math.random()*Mytrans.length+1);
targframe = Mytrans.splice(num,1);
gotoAndStop(targframe);
}


It sort of works, but still repeats, and obviously does not have the code to jump to the final frame.

Any ideas???

Random Jump To Frame Labels With No Repeats
Hi,

I have a flash banner in which I have 5 frame labels - lets say "a" "b" "c" "d" and "e".

I have been looking at this very helpful blog in which to randomly jump between these frame labels. Th blog is here:

http://www.quip.net/blog/2007/flash/...ithout-repeats

However, although this works really well, once all the labels in the array have been playing the animation stops, but I need it to shuffle the array again and then start playing them again in the new random order. I have been searching but can't seem to figure out how to do this as I am not a programmer.

can anyone help?

the script I am using is:


Code:
function shuffle(arr:Array):Void {
var len:Number = arr.length - 1;
for (var i:Number = len; i >= 0; i--) {
var p:Number = Math.floor(Math.random() * (i + 1));
var t:Object = arr[i];
arr[i] = arr[p];
arr[p] = t;
}
}

var labels:Array = ["a", "b", "c", "d", "e"];
shuffle(labels);

var currentLabel:Number = 0;
function gotoNextLabel():Void {
if (currentLabel < labels.length) {
gotoAndPlay(labels[currentLabel]);
currentLabel++;
} else {
stop();
}
}
gotoNextLabel();
Thanks for your time.

Steve

Random Function & Unique Random Numbers
Hello, after some searching i can't seem to find any good explanation to how and why i should use the Math.random() function so maybe i should explain how a function i need should work and someone maybe has some ideas.

I'm making a guessing program where you guess the right answer.

The function i have now randomly selects a number from 0 to 5 and then put's these five numbers into an array, the thing is that i need the numbers to be unique and i have no idea on how to make this.

Another thing i need to do is between these numbers that the random() function gets one is to be removed and instead i put the right answer there so now i also need one of the randomizes numbers to not be the right answer.

Also, how should a Math.random() function call look like so i can edit the range of numbers to randomize from?

Random Numbers
Hi, I'm trying to make a dynamic text box display a string of 4 or 5 numbers that rapidly change at random. I'm beginning to think that a text box may not be the way to accomplish this, but I'm at a loss. I've referenced my books, and the FLA's here on Flashkit, but just can't seem to find quite what I'm looking for. Any ideas? Thanks a lot for the help.

REALLY Random Numbers?
I have created a flash movie which creates a random number (eg 1-370) and then getsurl from a dynamic asp page based on that number. The result is a random tagline.

I hava noticed, however, that the taglines don't seem to be very random. Some of them are very frequently repeated while others are seldom seen.

Maybe it's just my idea but on the other hand maybe the random() function just doesn't work so well.

What do you think?

Is there a way to create randomer (!!!) numbers?

(I have though of getting a random number directly from the asp - visual basic script but I think this would be a waste of server resources)

Random Numbers
I was wondering if anyone knew of an Actionscript code that woudld randomly generate a number between 0-9 and continually loop. There would be a string of like 8 numbers that would continually change like I stated above? If you know of any tutorials that do this I would appreciate the link or site that has it. Thanks in advance! TC

Random Numbers ?
when using the random command is it possible to define where the random number starts . So it could be like
random (50-100); or would i have to put a check of sorts .

if (random>=49) {
gotoandplay ("sameframe");
}
else {
gotoandplay ("nextframe");
}

Random Numbers
How can you make flash choose a random number from a set? Such as {5, 10, 15, 20} or {-3, 0, 2, 13}

Also, how can you make random() generate negative and positive numbers?

DIFFERENT Random Numbers
I have a slot machine game, i need to make the slots stop at different icons. I use Math.random to go to different one son each slot. The problem is they always go to the same one. Can you try fix it, heres the .fla:
http://xtraterrestrial.orcon.net.nz/slotmachines.fla

Random Numbers
I'm working on a new project, where I have MC's coming down from the top of the screen...and I had them on Paths. But I didn't like how all of the animations were all the same, and it was predictable where the MC's were going to go. So I decided to write some code, and I decided to add a random number for each _y move of the MC. I added 'random (3) because I would add a number between 0 and 2 to the _y value of the MC. But I needed to also add negative numbers so that the MC would move back.

I need to know how I can get random numbers from the margin of -3 to +3. If anyone can post a reply that would be very helpful...thanks...

Random Numbers
Can somebody please help me out w/ random numbers. I'm trying to write a script that produces 8 different random numbers between 1 and 8. I need it not to produce duplicate numbers. Please help! I'm using Flash MX in case that matters.

-Nik-

Random Numbers?
Any of you guys play any game with HP (hitpoints) and when u get hit you lose hp... For this, I want to make a HP for a character and when it subtracts it goes a random number between 2 numbers... for example if its 1 - 10 the random number has to be between those... is this possible?

Random Numbers
What is the difference between
math.round(math.random(10)); and random(10); ??

I saw someone use the first option in a tutorial but didn't get the point..

Plz Help (random Numbers)
im tring to get txt boxes to generate random numbers without repeating a random number ive attached a file that should give you a better idea of what i mean

Random Numbers
I don't know where to post this really, but this forum sounds good.

I want to make little thing where you push a button and it gives a random number, from 1 to 99999999, it's for an experiment sorta. I'm using Flash 4. I'm pretty new to flash, so explain as best you can please.

Random Numbers
I'm trying to get a random number between -350 to 350. random() only gets number from 1 to 350. Is there anyway to get a negative and positive random number?

Random Between Two Numbers
Hi there!

I need to get a random number between two numbers. For example, to get an integer number between 10 and -10.

How can I do it?

Regards!

Random Numbers
Hello,

Is it possible to select random numbers? I am trying to select three different .jpgs that are numbered 1 - 12. Any help would be great!

Thanks,
DigitalMac

Random Numbers
Hey Forum,

I have created six text boxes on my program and I have got six random numbers being displayed out to them. The problem is that every now and again I get two of more of the boxes with the same number in them.

Could someone help me I want to get six unique numbers being displayed out isnt here is what i have any ideas. Still quite new to this.

random1 = random(49)+1;
random2 = random(49)+1;
random3 = random(49)+1;
random4 = random(49)+1;
random5 = random(49)+1;
random6 = random(49)+1;

Random Numbers
how to pick out 5 random different numbers from 22 numbers?

Random Numbers?
How do I make a random number that corresponds to the frame I want to go to?(I'm using Flash MX)

Random Numbers?
I have this to load a random pic from a folder. I have named the pics 1-57
this script look in the folder, makes a random number from 1 to 57 then adds the
.jpg to it then loads it in a movie I named picholder.

the problem is with the random number is if I where to have say two pic holders each with picholder1.loadMovie(Math.round(Math.random()*57)+ ".jpg");

I tend to still get the same number generated. So I thought I would and a number in to the generated number of the second random number so I would have something like this


picholder1.loadMovie(Math.round(Math.random()*57)+ ".jpg");
picholder2.loadMovie(Math.round(Math.random + 1()*56)+".jpg");

that way if they both get the same number (say 24) then picholder 2 would and a 1 to the number it loads making it a 25 so the output would be

picholder 24.jpg
picholder 25.jpg

the thing is I don't know ho to get that to work. any help?

Random Numbers
Hi,

I want to generate 3 numbers between 35 and 95 and would like the numbers to be at least 10 apart. For example: 38, 49, and 65. I'm using the following code to make sure the numbers are different but how do I alter it for the second constraint?

num1 = Math.floor(Math.random() * 61 + 35);
num2 = Math.floor(Math.random() * 61 + 35);
num3 = Math.floor(Math.random() * 61 + 35);
while (this.num1 == this.num2 || this.num1 == this.num3 || this.num2 == this.num3) {
num1 = Math.floor(Math.random() * 61 + 35);
num2 = Math.floor(Math.random() * 61 + 35);
num3 = Math.floor(Math.random() * 61 + 35);
}

Thanks a lot!

Random Numbers
Hello,
I have a random numbers text effect that I'm trying to accomplish with AS.
I have successfully created it on the timeline with by jumping to a new frame, but I have so many to do that wouldn't be time efficient.
-
Here's a link of what I mean:
http://www.micelistudios.com/random
-
The top red text is done with AS, BUT the problem is that I want the text letter spacing to be tighter, it seems only possible with one text box and this is done with a series of text boxes. The bottom grey text effect is what I want to achieve but with AS - DOES ANYONE KNOW HOW I CAN CONTROL THE LETTER SPACING AND ACHIEVE THIS EFFECT WITH AS AND USE A SINGLE TEXT BOX FOR THE ENTIRE SENTENCE ?

Random Numbers
I was wondering if there was an easier way to select a random number between:

-10 and 5 & 5-10

like choose one of these:

-10,-9,-8,-7,-6,-5,5,6,7,8,9,10

I know an easy was would be:

upordown = random number between 1 and 2

if(upordown ==1){
make random number between -10 and -5}
else{make number between 5 and 10}



Just wondering


Thanks!

Random Numbers
my mom is a teacher. i'm trying to make her a game to test her 3rd graders multiplication facts. i've got a timer set for two minutes, and in the two minutes they are supposed to answer some multiplicaition questions.



here's what i need help with.... i need TWO random numbers (1 through 12) to appear on the stage. (they CAN repeat)

**there needs to be a way the computer will check to see what the two numbers multiplied together would equal, to see if the students answers are correct. **




i'm a blonde, and still somewhat new on coding in flash... so explain things to me please! thanks!

Emily Pauline Davis

Copyright © 2005-08 www.BigResource.com, All rights reserved