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




Random Array



I have an array of different swf files that I would like to load as an intro page when you visit my site. There are several, I can already choose one specific piece from the array. I would like to select them randomly, so that everytime you visit you can see a new piece.



Ultrashock Forums > Flash > ActionScript
Posted on: 2005-04-12


View Complete Forum Thread with Replies

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

Pls Help: Need To Create New Array Taking 3 Random Entries From An Existing Array
Hello

I have a 2d array:

qTeeth[1] = [How many teeth do we have?, 1-10, 11-20, 21-30, 11-20]
etc.

It goes [question, option1, option2, option3, real answer]

I now just want to extract 3 or so of these entries and create a new array with them. Since I want to just use 3 or so questions randomly from a large array of questions.

Does anyone know a good tidy script to do this with??


Thanks in advance,
Ben.

Detecting Which Random AttachMovie Loaded From Random Array
I'm building a Freecell type card game. I've got an array that loads all of the cards (actually, the linkage names for each card loaded from the library with attachMovie). I randomize the array before I "deal the cards" onto the stage.

Here's a little code snipet where "deal" starts off equaling 0 and "cardDeck" is the value from my array (for example, c5 equals 5 of Clubs):


Code:
if (deal<52) {
_root.createEmptyMovieClip("card"+deal, deal);
_root["card" + deal].attachMovie(cardDeck[deal],cardDeck[deal],deal);
deal++
}
There's more, of course. My problem is - How can I detect which card loaded into which movie? For example, I know I have a movie called _root.card6 at the bottom of the first column, how can I know what card is loaded into _root.card6?

Generate Random Value From Array 'excluding' The Current Array Value
getting my head round flash (sorta!)...

ok, nearly got this working; i have 11 movie clips on the root timeline and a empty controller movie. what i need to happen is for a random movie clip to play. when it reaches a point in it's own timeline, it sets the playNext variable to true and the controller movie clip works out the next random movie to play.

the problem comes when the controller 'randomly' picks the movie clip thats already playing! then the whole thing breaks...

is there a way that i can say 'generate me a random clip to play from this array 'excluding' the currently playing movie clip'?

any suggestions would be grand.

this is what i have on my controller clip:

onClipEvent (load) {
//define a new array
video_array = new Array();
//list each of the videos
video_array[0] = "zero";
video_array[1] = "one";
video_array[2] = "two";
video_array[3] = "three";
video_array[4] = "four";
video_array[5] = "five";
video_array[6] = "six";
video_array[7] = "seven";
video_array[8] = "eight";
video_array[9] = "nine";
video_array[10] = "ten";
//this is the count of how many elements (videos) are in your array
max = video_array.length;
//set the playNext to true
_root.playNext = true;
}
onClipEvent (enterFrame) {
//if playNext is true
if (_root.playNext) {
//generate a new random video to play
randomNumber = Math.floor(Math.random()*max);
//store the name
randomVideo = video_array[randomNumber];
//tell that video to play
_parent[randomVideo].gotoAndPlay(13);
//record the video we are playing
crntVideo = randomVideo;
//set playNext to false
_root.playNext = false;
}
}

Generate Random Value From Array 'excluding' The Current Array Value
getting my head round flash (sorta!)...

ok, nearly got this working; i have 11 movie clips on the root timeline and a empty controller movie. what i need to happen is for a random movie clip to play. when it reaches a point in it's own timeline, it sets the playNext variable to true and the controller movie clip works out the next random movie to play.

the problem comes when the controller 'randomly' picks the movie clip thats already playing! then the whole thing breaks...

is there a way that i can say 'generate me a random clip to play from this array 'excluding' the currently playing movie clip'?

any suggestions would be grand.

this is what i have on my controller clip:

onClipEvent (load) {
//define a new array
video_array = new Array();
//list each of the videos
video_array[0] = "zero";
video_array[1] = "one";
video_array[2] = "two";
video_array[3] = "three";
video_array[4] = "four";
video_array[5] = "five";
video_array[6] = "six";
video_array[7] = "seven";
video_array[8] = "eight";
video_array[9] = "nine";
video_array[10] = "ten";
//this is the count of how many elements (videos) are in your array
max = video_array.length;
//set the playNext to true
_root.playNext = true;
}
onClipEvent (enterFrame) {
//if playNext is true
if (_root.playNext) {
//generate a new random video to play
randomNumber = Math.floor(Math.random()*max);
//store the name
randomVideo = video_array[randomNumber];
//tell that video to play
_parent[randomVideo].gotoAndPlay(13);
//record the video we are playing
crntVideo = randomVideo;
//set playNext to false
_root.playNext = false;
}
}

Random Array, Array Name Selected Randomly
Random Array, Array Name selected Randomly

Here is the code:

var RDNumber2x:Array = [2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36, 38,40];

var RDNumber3x:Array = [3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,48,51,54 ,57,60];

var RDNumber4x:Array = [4,8,12,16,20,24,28,32,36,40,44,48,52,56,60,64,68,7 2,76,80];

var RDNumber5x:Array = [5,10,15,20,25,30,35,40,45,50,55,60,65,70,75,80,85, 90,95,100];

var RDNumber6x:Array = [6,12,18,24,30,36,42,48,54,60,66,72,78,84,90,96,102 ,108,114,120];

var RDNumber7x:Array = [7,14,21,28,35,42,49,56,63,70,77,84,91,98,105,112,1 19,126,133,140];

var RDNumber8x:Array = [8,16,24,32,40,48,56,64,72,80,88,96,104,112,120,128 ,136,144,152,160];

var RDNumber9x:Array = [9,18,27,36,45,54,63,72,81,90,99,108,117,126,135,14 4,153,162,171,180];

var RDNumber10x:Array = [10,20,30,40,50,60,70,80,90,100,110,120,130,140,150 ,160,170,180,190,200];

var RArray:Array = ["RDNumber2x","RDNumber3x","RDNumber4x","RDNumber5x ","RDNumber6x","RDNumber7x","RDNumber8x","RDNumber 9x","RDNumber10x"];

var RArrayBox:String;
var RArrayBoxS = 0;


RArrayBox = RArray[Math.floor(Math.random() * RArray.length)];


RArrayBoxS = RArrayBox[Math.floor(Math.random() * RArrayBox.length)];


trace(RArrayBoxS);

Heres The error:

ReferenceError: Error #1069: Property 6 not found on String and there is no default value.
at randomarray_fla::MainTimeline/randomarray_fla::frame1()

What I am trying to atchieve is randomly selecting the array name and then randomly selecting something from that array.

So I am randomly selecting from a randomly selected array

Can anyone help with my problem?

Random Array
I'm back again. I just started with arrays a few weeks ago and am trying to get my big stupid head around them . I know how to retrieve them but what I want to do is when the user comes to a site he sees a random name every time . So in the main timeline I set a variable with an array called quotes
quotes["john","david", "Joseph", "ted","tim", "Jack"] I think you get the idea . Then in mc I have a dynamic text field called quote the code I have in there is
onClipEvent (enterFrame) {

Random Array Again
I still cant get this to work . I have a array set up in the main timeline .
quotes=["john","david", "Joseph", "ted","tim", "Jack"]
temp=parseInt( Math.random ()*5);
randomName=quotes[temp];

Random Mc`s From An Array...
Could someone help me out with this problem:
When I load an .swf with 12 thumbnails, I want the thumbs to fade in from alpha 0 to alpha 100, one by one (mc`s have alpha 0 when loaded).
The thumbs must be faded in a different order each time the movie is loaded.
I have made a start on it with this code, placed on the first frame on the main timeline. On the second frame is a loop action.

//
fade = new Array (image1, image2, image3, image4, image5, image6, image7, image8, image9, image10, image11, image12);
fadecount = fade.length;
index = Math.round (Math.random()*(fadecount-1));
to_fade = fade[index];

fadein = to_fade._alpha;
fadein++;
//

Somehow I have to store the faded mc`s in an array and pick another random number until the fade-array is empty.

Am I on the right track here?

Random Array Nearly There
not set the timer totally up yet.this is so that it waits a while before ti picks again.

problem with this script more than one plays at a time..whats wrong?
please help?


onClipEvent (enterFrame) {
if (timer ==1 ){
startArray = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16];
endArray = [];
while (startArray.length>0) {
i = Math.floor(Math.random()*startArray.length);
// a random item from startArray
item = startArray[i];
// add this item to endArray
endArray.push(item);
// and them remove it from startArray
startArray.splice(i, 1);
// objArray.splice(i, 1);
_root.world["alien"+i].gotoAndPlay(2);
timer++;
}

} else {
timer++;
}
}

Random Array
i need to make something that will randomly access data from an array.

like on the pokie machines. except i need text.

all i have now is

text = new Array("blah1","blah2","blah3","blah4","blah5")

rand = random([text])

can someone help

Random Value Array
I am creating some kind of minesweeper. I must take 10 values out of an array but when a value is already taken it must take another. Can somebody help ...

Kenny



for (var i = 0; i<aantalbommen; i++) {
var bommenlijst = new Array(11, 12, 13, 14, 15, 16, 17, 20, 21, 22, 23, 24, 25, 26, 29, 30, 31, 32, 33, 34, 35, 38, 39, 40, 41, 42, 43, 44, 47, 48, 49, 50, 51, 52, 53, 56, 57, 58, 59, 60, 61, 62, 65, 66, 67, 68, 69, 70, 71);

posbom_temp = random(bommenlijst.length);

posbom = bommenlijst[posbom_temp];
this["vakje"+posbom].blokjestype.blokjestype = "mijn";
trace('bom '+i+': positie '+posbom);
}

Random Array
Im making a game and I need to be able to choose 10 numbers at random between 0 and 100 and put them into an array then I need to be able to find the biggest of the numbers and set that number as a variable so I can test if the wright answer is chosen. That wasn't expained very well, so...erm ill draw something



array: 10 random number (0-100)

function answer: this would find the biggest number in the array and set that number as a variable called "answer"

I need this very quickly so any help would be greatly appreciated.

Random Array
How can I create a grid of tiny grey squares (EG:100x50 squares), and have them turn into a different color (eg black) randomly one by one?

http://sony.net/

I want to achieve something like those squares and those types of transitions.

Also, anybody know a good font that looks like that?

Thanks


--iMat

Random Array
this script loads a RANDOM SWF into mcholder

-----------

lastNumber = randomNumber;
movies = new Array("3com.swf", "abes.swf", "abta.swf");
tempMovies = movies;
newMovie = Math.floor((Math.random()*tempMovies.length));

_root.mcholder.loadMovie(tempMovies[newMovie]);

--------

Now I want to random the rest of the array but not the elements that were loaded before...

example:
- first time: it will random between 1-3... I got a 2
- second time: it will random 1 or 3.... I got a 3
- third time: I will get a 1
- fourth time: it will random between 1-3 AGAIN

and so on...
someone help me pleaase...

Random Array
Hi

Is there a function that randomizes the order of all elements in an array.

thanks
scarlac

Random Array
Hi all!!!, I want to acces an array using random, how can I use it??

Thanx for the help

Mike

Random Array
var question = new Array;

question [0] = "string 1";
question [1] = "string 2";
question [2] = "string 3";
question [3] = "string 4";

My goal is when next time the array loads, the sequence should be changed randomly like,

question [3] = "string 1";
question [1] = "string 2";
question [0] = "string 3";
question [2] = "string 4";


( or )

question [0] = "string 3";
question [1] = "string 1";
question [2] = "string 0";
question [3] = "string 2";

no repetation should be there, all the 4 strings should be assigned for 4 arrays.

XML To Array Then Random
Hi All.

I have created an xml doc that holds 2 values (although I will be adding to the values in time)


HTML Code:
<?xml version="1.0"?>
<urls>
<url>
<name>AAAAA.swf</name>
</url>
<url>
<name>BBBBBB.swf</name>
</url>
</urls>
I want to load these two values into flash then put them into an array, then use "random" to choose a random id from the array.
I want the script to still work if there are more valus in the xml.. here is where im at:


HTML Code:
function loadXML(loaded) {
if (loaded) {
_root.urls = this.firstChild.childNodes[0].childNodes[0].firstChild.nodeValue;
} else {
trace("file not loaded!");
}
}

xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("urlz.xml");

urlvar = ["YSYC.swf", "CS_Havering3.swf"];

// i = urlvar.length;
// k = Math.floor(Math.random()*i);
loadMovieNum(urlvar[k], 2);

stop();
I think my issue here is getting the values into the array and getting the array length 2i"

Random Array
can anybody help me to choose a random array and not choose it again if it play again
so i pick one randomly from it and i don't need it again








Attach Code

myarray1 = new Array(1, 2, 3);
myarray2 = new Array(4, 5, 6);
myarray3 = new Array(7, 8, 9);
r2 = random(3)+1;
mm = eval("myarray"+r2);

Random FLV's From Array
Hi!
I' am trying to randomly load 10 short video clips. The script below doesn't work properly. It plays the first video clip randomly, but then nothing else happens. Please answer my questions below.

script:

var VideoArray = new Array();
VideoArray = ["Q1.flv", "Q2.flv", ......"Q10.flv"];

var currentVideo =random(9);

my_video.play(VideoArray[currentVideo]);

var listenerObject:Object = new Object();
listenerObject.complete = function(eventObject:Object):Void {
VideoArray = random (9)
};
my_video.addEventListener("complete", listenerObject);

QUESTIONS:

1. How to randomly load FLV's?
2. How to make the loaded videos not play automatically?

Thanks for your help.


German
Please check my script and suggest ways to make it work.

Array + Random
Code:
var Count:Array = new Array();

trace (Count)
// _level0.thumbnails.thumb0,_level0.thumbnails.thumb1,_level0.thumbnails.thumb2,_level0.thumbnails.thumb3,_level0.thumbnails.thumb4,_level0.thumbnails.thumb5,_level0.thumbnails.thumb6,_level0.thumbnails.thumb7,_level0.thumbnails.thumb8,_level0.thumbnails.thumb9,_level0.thumbnails.thumb10,_level0.thumbnails.thumb11


bttn.onPress = function() {
var myRandom:Number = random(Count.length);
var goAnimate = animationClips[myRandom];
var fadeTween = new Tween(goAnimate, "_alpha", Regular.easeOut, goAnimate._alpha, 0, 20);
};

Since
Count.length = 12
its like
myRandom:Number = random (12);
============================================

How to make sure, i am cycling between random (12)
Without getting the same results.
But just a cycling between 1 and 12, properly.


Greetz

RANDOM ARRAY
Have put this together but the return value is not what I exspected.
Basically I want one of the four array objects to be randomised.

the_Dates = ["1993", "1992", "2000", "1992"];


onEnterFrame = function(){
var Randoniser = (Math.random(the_Dates.length));
trace(Randoniser);
}

return in the trace
1993
2000
1992
2000
1993
2000
(or something like that)

I know its my syntax and probably the methods i have used that are in appropriate.

Random Xml Array
Hi all,

can someone tell me how can I take one slogan (with all his nodes, bigLines & smallLines) randomly from this xml doc? I use xpath for quering xml: sloganId= XPathAPI.selectSingleNode(this.firstChild, "/catalog/slogan").attributes.ID;

<?xml version="1.0"?>
<catalog>
<slogan ID="0">
<bigLine>Sustainability for all-</bigLine>
<bigLine>tree-hugging optional.</bigLine>
<bigLine>See how we do it.</bigLine>
<smallLine>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</smallLine>
<smallLine>Research Center</smallLine>
</slogan>
<slogan ID="1">
<bigLine>Big, very big buildings</bigLine>
<bigLine>with your signature.</bigLine>
<bigLine>We are different.</bigLine>
<smallLine>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
</smallLine>
<smallLine>Some Foundation</smallLine>
</slogan>
<slogan ID="2">
<bigLine>Client relationships</bigLine>
<bigLine>older than our interns.</bigLine>
<bigLine>Visit us, take your time.</bigLine>
<smallLine>Here is some witty copy about the communications.</smallLine>
<smallLine>Discovery Communications</smallLine>
</slogan>
</catalog>

Array With Random
Hi i have some questions in swfs, and i need to let them be shown randomly...But how,

I have them in a array i can get a random swf out using Math.random, but how do i cross that one off so it doesnt come up again???

hope someone can help..

thanks

Stephen

Random Array
could someone tweak this code to choose randomly from these variables in this array?

_root.mwith.heading = ["item1", "item2", "item3", "item4" ];
_root.mwith.floatingheader.slider.slidertext.text = _root.mwith.heading[i];
if (i<12) {
++i;

} else {
i = 0;
}
stop();


Thanks in advance.

Random Array..
Hi,

I have a php file containing information that looks like this....


PHP Code:



menu_count=2&menu_title_1=Alli With An I Website&menu_client_1=Alli With An I&menu_tech_1=Flash, PHP&menu_img_1=images/thumb1.jpg&menu_url_1=http://www.alliwithani.com/&menu_state_1=1&menu_title_2=Alli With An I E-Card&menu_client_2=Alli With An I&menu_tech_2=Flash, XML, PHP&menu_img_2=images/thumb2.jpg&menu_url_2=http://alliwithani.com/flash_player/&menu_state_2=1&menu_loaded=1 




Of course I'll add more later and it'll be running from my database allowing me to update from a personal control panel I built.

I have it loading into flash and duplicating a movieclip to display all the projects into a list so people can select them. Here is the code I have for the looping of the MC...


Code:
// This loop duplicates a template movie clip and prepares it based on the information set in "menudata.txt".
item_spacing = 20;
x = 1;
while (Number(x)<=Number(/:menu_count)) {
duplicateMovieClip("menu_template", "item_" add x, x);
tellTarget ("item_" add x) {
menu_title = eval("/:menu_title_" add ../:x);
menu_client = eval("/:menu_client_" add ../:x);
menu_tech = eval("/:menu_tech_" add ../:x);
menu_img = eval("/:menu_img_" add ../:x);
menu_url = eval("/:menu_url_" add ../:x);
gotoAndStop(eval("/:menu_state_" add ../:x));
setProperty("", _y, Number(getProperty("", _y))+Number((..:item_spacing*(../:x-1))));
}
x = Number(x)+1;
}
stop();
It works fine. It loads them into a list as needed. Then if you click on one of the button/mc's it loads the information into a seperate movieclip like I need. But where I run into trouble is that I can't seem to have it automatically load the first set of arrays into the seperate movieclip. That way when people enter that page it's already loaded a project's info in there for them to view, rather than staying blank til they click on one of the buttons. I don't know if some of you can possibly help me add something to the above code to have it select one of the items and send it to the mc right away.

Thanks for your time!

Evan

Array Random
hi guys!
i want words random by example
in the output "two" then test movie "six" then test movie "one"
what is the mistake??
excuse me english

words = ["one ","two ","three ","four ","five ","six "]
for(var i=0;i<words.length;i++) {
words[i]+=random(10)
trace(words[i])
}

Array With Random Function
Can anyone help me with this problem I have a array in the main timeline.
quotes=["john","david", "Joseph", "ted","tim", "Jack"]
temp=parseInt( Math.random ()*5);
randomName=quotes[temp];

Then I have a MC with a dynamic text field inside it and on the mc clip I have
onClipEvent ( enterFrame ) {
this.quote=_root.randomName[temp];
}

I want the names in the array to come up random every time the user launches the MC with the Dynamic text field in it .
The code seems correct but it doesn't work . What am I doing Wrong.

Random Sort Of An Array
here's the problem:

i have a bit of actionScript that generates an array of filenames. basically it looks like this :
loadOrder= ["slideshow/soul1.swf", "slideshow/soul2.swf","slideshow/fashion1.swf","slideshow/fashion2.swf", etc];

there are 12 .swf files in six categories, for a total of 72 files.

now, i want to randomly determine the load order of these files, each time the user accesses the parent .swf. currently, i have the file randomly choosing one of the 72 files, but is there a way to either:

1. randomly sort the array each time so that i can just access in order from index 0 to 71?

or

2. randomly select a number from 0 to 71, but not repeat a number until all 72 possible files have been chosen?

i've tried a few different solutions, but they all seemed to be more complex than should be necessary. am i over thinking this problem, or is it a tricky one?

thanks in advance.

d.

Random Hex Colors From Array
-thanks for dropping in-

This is an attempt to randomly draw 14 colors from a 21 color array. I think everything is correct, but when the 'frame' runs the script, all the objects turn black (0x000000).

Perhaps this is because of a hex color problem with Flash?
I don't know... been messing with it for hours and nothing works.

I think the problem lies in the setRGB() method.
The setRGB() method works when I place a static hex color in it (ex. setRGB(0xFF0000))
There is content in the colorsSelect[Array] when I test by writing it to a dynamic text field.
But when I plug everything together, it causes all the objects to turn black.

Any assistance or ideas would be much appreciated.
Thank you.

=========================================
**(actions in Frame 1 of main timeline)**

// new array with 21 predetermined colors
colorsArray = new Array("0xFF0000", "0x0000FF", "0x990000", "0x996600", "0x99CC00", "0xCC6600", "0xCCCC00", "0xCCFF00", "0x990066", "0x99FF66", "0x9900FF", "0x99FFFF", "0xCC00FF", "0xCCFFFF", "0xFF00FF", "0x00FFFF", "0x000099", "0x006699", "0x00FF99", "0x00FF00", "0xFFFF00");
// filled with 14 random from colorsArray
colorsSelect = new Array(14);
// keep track of random numbers generated
colorsChosen = new Array(14);

// fill colorsSelect array with 14 random colors from colorsArray
for (var randColor=0; randColor<14; randColor++) {
var randNum = Math.floor(Math.random()*21);
for (var compColor=0; compColor<14; compColor++) {
if (randNum== colorsChosen[compColor]) {
var randNum = Math.floor(Math.random()*21);
continue;
}
}
colorsChosen[randColor] = randNum;
cchosen = colorsArray[randNum];
colorsSelect[randColor] = cchosen;

===========================================

**(in Frame actions to generate object colors)**

if ((i <= 7) and (p == 0)){
var pleasepiece = _root.menu["ppiece"+i];
var piececolor = new Color(pleasepiece);
var pieceC = String(_root.colorsSelect[i]);
piececolor.setRGB(pieceC);
i++;
}

------------------

I know there must be ways to streamline and clarify this code. Perhaps my actions should be on the onClipEvent()?
But I had this working with random hex colors and static values. what is the block here?

Thanks again.

Random Extern Swf From Array
hi!
how can i load extern swf´s from an array randomly on my scene?
the target should be a empty mc!
sorry for my english i´m french :-)

kondition = new Array();
kondition[1] = "10%.swf";
kondition[2] = "10%_2.swf";

Random Array Without Repeatment?
How do I make the elements of an array display randomly without repeatment? What I've got so far is the following:

menu = ["a", "b", "c", "d"];
for (i = 0; i < menu.Length; i++){
trace (menu[Math.floor(Math.Random() * 4)]);
}

Thanks in advance

Random Array Sort
does anyone have a script that randomly sorts an array of length n?

thanks,
dave

Pick Random Value In Array And...
Hello

How do I make a random choice in an array, and when a certain object is picked, the next time it can't be picked, only after all the objects in the array have beem picked. For example:


Code:
cities = new Array();
cities = ["New York", "London", "Rio de Janeiro"];


Say that in the first time, the function randomly picks index number 1 ("London"). In the second time, it can only pick either indexes 0 or 2. If it randomly picks 0 ("New York"), the next time it can only pick index 2... when it finally picks index 2, the function sees that all the possible indexes have already been picked, then it starts over, meaning that in the fourth time you can pick any of the three indexes.

I have tried to do this using loops, using length, splice, slice, everything, put I think I am too slow to figure out the problem! Please help meeeeeeee!!! :confuse:

Best regards
Daniel

Random Array Text
I'm very new to scripting.
I created an array with quotes and want to display them randomly in a text field when the uesr views. I searched the forums and found nothing usefull. This is my array of quotes.
How may I display them in a text field randomly?
the text field var is whichOne

var quoteList=new Array(6);
quoteList[0]= "Someday I want to be rich. Some people get so rich they lose all respect for humanity. That's how rich I want to be. Rita Rudner" ;

quoteList[1]= "My problem lies in reconciling my gross habits with my net income. Errol Flynn (1909 - 1959)" ;

quoteList[2]= "The first half of our lives is ruined by our parents, and the second half by our children. Clarence Darrow " ;

quoteList[3]= "People who say they sleep like a baby usually don't have one. Leo J. Burke" ;

quoteList[4]= "The power of accurate observation is commonly called cynicism by those who have not got it. George Bernard Shaw" ;

quoteList[5]= "When you have only two pennies left in the world, buy a loaf of bread with one, and a lily with the other. Chinese Proverb" ;

Random Number Within Array
I've got an array which contains the numbers 2-10, and I need to randomly select a number from this array. Once chosen, this number then needs to be removed from the array so that it can't be selected again. I'm using Flash MX.

Once again, any help would be very welcome.

Thanks.

Select Random Array.
Ok so I'm working on a portfolio for my personal site. I'm going to have it run off of a php backend so I can update it from my control panel I made. Well anyways. I have a rough draft going and it's working ok so far. When it loads in the text file it displays the buttons like it is supposed to ok. But what I'd like to do is have it so once all the buttons are loaded in it automatically selects one randomly from the list and displays the content. Rather than keep it blank til someone clicks a button. Catch what I'm saying?

Thanks a ton and I hope someone can help/direct me in the right direction.

Evan

Get Random Element From Array
apologies for this easy question but I'm new to actionscript and flash!

I have an array with a list of things, and I simply want to pick out a random element from the array. How can I do this?

I was trying to solve this by having a random number, multiply by 10, then have a function to call to check whether it is greater than the count of the elements in the array, but this seems long-winded and it didn't work anyway!!!!

Thanks.

Random Non-repeating Array
I have searched numerous threads and have not found an answer to this problem that I can apply to my project.

I have an array with the numbers 1-24. iwant it to generate a number from the array put it in the gotoandplay(IN HERE); then take it out of the array until all the numbers are gone. Here is one of my many attempts below: I know there must be an easier more condensed way of doing this.

Any help is appreciated.

code:
mytiles = new Array();
mytiles = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24'];
randTile=int(math.random()*mytiles.length);
mytiles.splice(randTile,1);
tile1.gotoAndPlay(randTile);
randTile2=int(math.random()*mytiles.length);
mytiles.splice(randTile2,1);
tile2.gotoAndPlay(randTile2);
randTile3=int(math.random()*mytiles.length);
mytiles.splice(randTile3,1);
tile3.gotoAndPlay(randTile3);
randTile4=int(math.random()*mytiles.length);
mytiles.splice(randTile4,1);
tile4.gotoAndPlay(randTile4);
randTile5=int(math.random()*mytiles.length);
mytiles.splice(randTile5,1);
tile5.gotoAndPlay(randTile5);
randTile6=int(math.random()*mytiles.length);
mytiles.splice(randTile6,1);
tile6.gotoAndPlay(randTile6);
randTile7=int(math.random()*mytiles.length);
mytiles.splice(randTile7,1);
tile7.gotoAndPlay(randTile7);
randTile8=int(math.random()*mytiles.length);
mytiles.splice(randTile8,1);
tile8.gotoAndPlay(randTile8);
randTile9=int(math.random()*mytiles.length);
mytiles.splice(randTile9,1);
tile9.gotoAndPlay(randTile9);
randTile10=int(math.random()*mytiles.length);
mytiles.splice(randTile10,1);
tile10.gotoAndPlay(randTile10);
randTile11=int(math.random()*mytiles.length);
mytiles.splice(randTile11,1);
tile11.gotoAndPlay(randTile11);
randTile12=int(math.random()*mytiles.length);
mytiles.splice(randTile12,1);
tile12.gotoAndPlay(randTile12);
randTile13=int(math.random()*mytiles.length);
mytiles.splice(randTile13,1);
tile13.gotoAndPlay(randTile13);
randTile14=int(math.random()*mytiles.length);
mytiles.splice(randTile14,1);
tile14.gotoAndPlay(randTile14);
randTile15=int(math.random()*mytiles.length);
mytiles.splice(randTile15,1);
tile15.gotoAndPlay(randTile15);
randTile16=int(math.random()*mytiles.length);
mytiles.splice(randTile16,1);
tile16.gotoAndPlay(randTile16);
randTile17=int(math.random()*mytiles.length);
mytiles.splice(randTile17,1);
tile17.gotoAndPlay(randTile17);
randTile18=int(math.random()*mytiles.length);
mytiles.splice(randTile18,1);
tile18.gotoAndPlay(randTile18);
randTile19=int(math.random()*mytiles.length);
mytiles.splice(randTile19,1);
tile19.gotoAndPlay(randTile19);
randTile20=int(math.random()*mytiles.length);
mytiles.splice(randTile20,1);
tile20.gotoAndPlay(randTile20);
randTile21=int(math.random()*mytiles.length);
mytiles.splice(randTile21,1);
tile21.gotoAndPlay(randTile21);
randTile22=int(math.random()*mytiles.length);
mytiles.splice(randTile22,1);
tile22.gotoAndPlay(randTile22);
randTile23=int(math.random()*mytiles.length);
mytiles.splice(randTile23,1);
tile23.gotoAndPlay(randTile23);
randTile24=int(math.random()*mytiles.length);
mytiles.splice(randTile24,1);
tile24.gotoAndPlay(randTile24);


Thanks Muchly,

Mark

Array.sort Random?
Hi,

how can I use array.sort to have a random order in my array ?

thanks for any help
boombanguk

Random Mc's To Play From Array
HI
I would like that when an event is triggered that random mc's play.
I guess it makes sense to put them into an array and then have them play from there.
I a just not sure how to do this. I am kinda ok with Arrays, just learning really.
I would like it that so when one clip finishes another plays in its place from the array without any user input.
An on event to start the random playing from the array and another on event to
stop it and return to the original mc.
Any help with this would be well appreciated...

In plain (ish) English it would be something like this; On mouse event replace my_mc with an library instance at random. After the mc has played once.. (or thrice,, whichever) then replace that instance with another from
the library.. On the next mouse event return to the original my_mc...


Thanks

Trug

Random Array Question
Hi All,

I'm working in flash 8

I have been searching for an answer to my question for a good hour now and have come to the conclusion that I may be asking the wrong questions.

I would like my movie to randomly select a keyframe to start at each time it is loaded. Say if I have 10 keyframes labled 1-10 I would like my script to randomly select 1 of these 10 positions each time the movie is loaded. I have been searching far an answer using keywords such as random and array but can't seem to find anything specific to my purpose. If anyone could direct me to an example of this working it would be much appreciated.

Cheers.

Random(array.length); ?
Hey everyone

I just read that random(4) will choose between 0, 1, 2 and 3.... but not 4.

When I write random(array.length) with this array:

[0] = "hey";
[1] = "hey again";
[2] = "will this also be left out?"

.. will the random function then only choose between [0] and [1] or will it choose a random number from both [0], [1] and [2]???

Random Vars From An Array...
Ok here's what i'm trying to do...

I'm creating an simple higher and lower game.... using products and prices ..

i've got 15 products with prices...

and two different var text fields.. on for products other for prices...

i need the two to hook up that's my first problem..

I've created two arrays.. one for products and the other for prices.. the linking ones are number the same

say fishbowl is product array [1] and fish bowl prices is price array [1] etc..

now i'm trying to get these arrays to randomise in a five card flop out..

so it will make the 5 text fields above the cards.. random products and the 5 text fields under the cards with the matching prices..

i've coded the script for the higher lower.. this just uses if price1 <= price 2 method.. nice and simple

so what i'm trying to do in a nut shell is

randomize the products and make sure the price field matches..

if that makes any sense..

i've thought about creating 15 sep cards.. and pulling them all in randomly but this would be more timely and prob would involve recoding the whole of the higher lower script..

any help would be most grateful.. i've played with the random function before yes this create random numbers but i'm not sure if i could do it with arrays and then link them to the right price..

Andy

Random Letters With Array
Hi
I've a function which returns random letters made with an array
I want to display the result in a dynamic text field but it doesn't work
i attached the files
thanx bye

Random Frame From Array Help Please
Hi all. I have a problem I was hoping someone could help me out with
I have a game that requires I select a random frame from the root timeline from an array of frames, the fla is too big to post and I really cant bring it down to size so I will have to describe it
the timeline has 3 keyframes before the frames I need randomized, so I can not just to a gotoAndPlay(random. yaddy ya)
now the randomizer script goes on the first frame of the frames I want randomized (doesnt work putting them anywhere else) that script looks like this

Code:
function arrayRandomizer(a, b) {
var value = (random(2)==0) ? -1 : 1;
return value;
}

frames = ["q1","q2","q3","q4","q5","q6","q7","q8","q9","q10","q11","q12","q13","q14","q15","q16"]; // this is the array of frames
frames.sort(arrayRandomizer);


currentFrameCount=1;
function nextFrame() {
if(++currentFrameCount<frames.length){
gotoAndStop(frames[currentFrameCount]);
} else {
_root.gotoAndStop("end");
}
}

so what happen is that the game starts on "q1" and that keyframe has some timer controls and what not, but the frame is not removed from the array, its not recognizedm, thus it will be selected later on and reset the timer controls. if I remove the "q1" from the array, the game ends one frame short of what it should be. Anyone know what I mean?

is there a better wat to randomize frames on the root timeline?
wait, here is a link to the fla, make it easier. www.cambridgeeikaiwaschool.com/fruit.fla

thank you in advance

Mark

Array With Random Display
Hello,

I have a script that I can't get it to do what I want. I want to read the array then randomly pick an item (this works). Then I want the code to delete "the item" that it picked "only" from the array! My script below does reduce the array size each time (17, 16, 15 etc) but I need the specific "word #" removed...



// list of movies
wordArray = ["word0", "wordd1", "wordd2", "word3", "word4", "word5", "word6", "word7", "word8", "word9", "word10", "word11", "word12", "word13", "word14", "word15", "word16"];

//get the length
wordLength = wordArray.length;
//pick a random number
r = Int(Math.random()*wordLength);

trace("word"+r);

//remove the word we have picked from the array
wordArray.splice(r,1);

Can anyone see the problem???

[F8] Random Sound From Array
I'm trying to make a remake of that old gameshow "name that tune". I can't figure out how to load a random song from my "song array" though.
code:
var song_Array:Array = new Array();
song_Array = ["song1.mp3","song2.mp3","song3.mp3",etc]


Well thats as far as I've gotten. Tried using loops,random,etc.

Random (simple) Array
I am trying to setup an array of 2 moviclips which are on the stage and then once the button is pressed it plays frame 2 of one of the random clips. If I write the array like this;


Code:
var clipArray:Array = Array["clip1_mc","clip2_mc"];
How do I then implement the rest of this? I know I need to write the Math.round code but not sure how to use this. Any help would be great.

thanks
jb

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