# Random non repeating variables

**URL:** https://forum.kirupa.com/t/random-non-repeating-variables/184339
**Category:** flash
**Created:** [April 4, 2006, 1:41pm UTC](https://forum.kirupa.com/t/random-non-repeating-variables/184339 "2006-04-04T13:41:41Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![greendog](https://avatars.discourse-cdn.com/v4/letter/g/e8c25b/32.png) [@greendog](https://forum.kirupa.com/u/greendog)
#### Post date: [April 4, 2006, 1:41pm UTC](https://forum.kirupa.com/t/random-non-repeating-variables/184339/1 "2006-04-04T13:41:41Z")

</div>

OK I’m somewhat descent at Actionscript, but I’m brand new to arrays. I know very little about them. It seems at the moment I’m going to have to make use of them.  
Here’s what I’m doing:  
I’m creating a flash game in which you are a UFO flying over a group of cows and you have to abduct them. It’s a top view game so I have the grass moving from top to bottom and I have a movie with 5 cows and theres a controller in the \_root movie that creates a random variable:  
\_root.cows = random(5);  
Now everytime the controller movie gets to a certain frame, that frame tells the cow movie to play a certain cow (Moving from top to bottom) based on the current variable.  
What’s happening is when there is a repeat, the cow disapears and jumps back to the top. Seeing how there’s only 5 cows you can tell this happens a lot.

Now I’ve researched this a bit and found that I can create an array of random numbers and splice each one as I’ve used it. I’ve tried this, copied different codes and I can’t get it to work.  
I’m probably placing it wrong or something, but being a man who is used to his variables, maybe I’m doing something the wrong way. Please explain, if anyone can, how I can do this…and if possible explain as if talking to a third grader. 😃 thanks

---

<div class="post-metadata">

### Author: ![stringy](https://avatars.discourse-cdn.com/v4/letter/s/919ad9/32.png) [@stringy](https://forum.kirupa.com/u/stringy)
#### Post date: [April 4, 2006, 3:10pm UTC](https://forum.kirupa.com/t/random-non-repeating-variables/184339/2 "2006-04-04T15:10:33Z")

</div>

> [@greendog](#):
>
> OK I’m somewhat descent at Actionscript, but I’m brand new to arrays. I know very little about them. It seems at the moment I’m going to have to make use of them.  
> Here’s what I’m doing:  
> I’m creating a flash game in which you are a UFO flying over a group of cows and you have to abduct them. It’s a top view game so I have the grass moving from top to bottom and I have a movie with 5 cows and theres a controller in the \_root movie that creates a random variable:  
> \_root.cows = random(5);  
> Now everytime the controller movie gets to a certain frame, that frame tells the cow movie to play a certain cow (Moving from top to bottom) based on the current variable.  
> What’s happening is when there is a repeat, the cow disapears and jumps back to the top. Seeing how there’s only 5 cows you can tell this happens a lot.
> 
> Now I’ve researched this a bit and found that I can create an array of random numbers and splice each one as I’ve used it. I’ve tried this, copied different codes and I can’t get it to work.  
> I’m probably placing it wrong or something, but being a man who is used to his variables, maybe I’m doing something the wrong way. Please explain, if anyone can, how I can do this…and if possible explain as if talking to a third grader. 😃 thanks

see if this helps

> **[kirupaForum](https://forum.kirupa.com)**
>
> Got a web design/development question or just want to hang out with the most awesome people on the planet? Drop on in!

Another way is to shuffle the array and then loop through it in order

---

<div class="post-metadata">

### Author: ![greendog](https://avatars.discourse-cdn.com/v4/letter/g/e8c25b/32.png) [@greendog](https://forum.kirupa.com/u/greendog)
#### Post date: [April 4, 2006, 5:12pm UTC](https://forum.kirupa.com/t/random-non-repeating-variables/184339/3 "2006-04-04T17:12:20Z")

</div>

> [@stringy](#):
>
> see if this helps  
> [http://www.kirupa.com/forum/showthread.php?t=214484](http://www.kirupa.com/forum/showthread.php?t=214484)  
> Another way is to shuffle the array and then loop through it in order

I’m sorry  
I’m lost
