ActionScript 2.0 :: Load A Random Vaule From An Array
Jan 12, 2008
I can't get my head around arrays.Ok so basic I know it can be displayed as blah then you can retrive with trace(blah[X]); or in a text box.I can't be bothered with the var blah:Array = []ect.. I want to stay simple.I want to load a random vaule from an array but I want to keep the code simple so I can come back to it and instantly understand and make changes.
I want a movieclip consisting of a dynamic text box that, from the time it's loaded onto the stage, loads a randomly selected text string from an array, and continues to loop until the clip is removed from the stage. I also want the text strings to appear in the text box for random intervals between 500 and 3000 milliseconds.
While I've found tutorials here and elsewhere on loading one element from an array, usually triggered by a button, I don't know how to combine/alter it with the other elements.So I want this movieclip on the stage randomly flashing phrases from an array, some for a barely perceptible time, and others for a readable time.
I've been putting data into an array via XML, and then selecting at random an image string to load in a pic at random. But whilst doing this, I wanted to remove the String from the Array that I have just used, so I don't get repetition of the same image in the output. I initially thought that pop would remove the string I had just used - But of course it Removes the last value in the Array instead, which doesn't really help.
Ok - so how about randomizing the data once inside the Array, after it has been pulled in from XML!? That way I can load in the 'last' image, and then pop it out! Keeping a randomized selection of images each time 'it' is loaded
I have this to load a random image from my array. But how can I keep track so that a new random pic wont be the same as one allready shown, until all pics in the array has been shown once?
I have 15 empty placeholder on my stage, named "empty01" - "empty15". I have 15 mcs in my library, with linkage identifiers "01" - "15".
[CODE]...
I would prefer for 'empty01' to load a random mc. Can anyone advise how I could achieve this? I have tried to create an array containing the 15 library mcs (not sure if this is correct):
I'm trying to use an array adapted from AS2 script to load random swfs called "koan_1.swf" or "koan_2.swf" etc into a "koan_loader_mc" on the stage. Each "koan_#.swf" has code in its last frame to both advance the "shuffle" array in the action script in the first frame of the stage and to load the next koan swf. The code below -- almost -- works, but....?
Frame on main stage:
// creates function called at the end of koan_#.swfs function shuffle(a:Array) { for (var ivar = a.length-1; ivar>=0; ivar--) {
I don't think I'm as familiar with arrays as I need to be to complete the following project - I've read about 60 posts and no one seems to be doing exactly what I am. Here's what I need to do: From a main swf (home.swf), I need to load 7 consecutive swfs in random order, (movie01.swf, movie02.swf, etc) from an array, into level 1. I need all seven to play without repeating, then repeat them in the same order in a loop.
But I ALSO need the user to be able to navigate through the swfs by using next or previous buttons (or by selecting individually 1-7, but that may be asking too much from my limited knowledge).Here is the code I'm using to generate a random ordered array:
I have 4 groups of movieclips all with different names.
Example:
Group1 contains dog_mc, cat_mc and bird_mc Group2 contains shoe_mc, hat_mc and pants_mc etc...
What I am trying to do is load a random group initially (either 1-4), then I want to play that group of movieclips. Once that group is completed playing all its movieclips, I want to move on to the next group and play all those movieclips. When all groups and movieclips have completed, I want to loop back to the start.
im playing with the load random movie (but loading a random xml file instead) based on the wonderful tutorial from front page and was wondering whether anyone can show me the work around/upgrade to AS2 for this bit of script since im publishing to Flash 8 /AS2 and it doesnt work:
I would like to use an array to play 5 sound files randomly.Here's the code I've got so far! Can anyone tell me what code I'm missing?
var my_sounds:Array = [Sound1, Sound2, Sound3, Sound4, Sound5]; var s1:Sound = new Sound(new URLRequest("GentleSeaOnFlatBeach.wav"));var s2:Sound = new Sound(new URLRequest("SPLASH.wav"));var s3:Sound = new Sound(new
I've got the following script that loops an array of movieclips at random positions in and out of the stage using Tweener. My problem is that the loop uses all the movieclips (WELCOME00, WELCOME01, etc.) at once. What I'd like is for the loop to only use one of the movieclips, chosen at random, for the loop instead of all of the movieclips listed in the array at one time.
Code: import caurina.transitions.*; var mcArray:Array = [WELCOME00, WELCOME01, WELCOME02, WELCOME03]; var init:Boolean = true;
I have an assignment where I need to create an array with 9 numbers between 1 and 34, also none of the numbers need to appear twice.This is what I have so far, so as you can see I'm stuck on the part where I have to check if the number already exists in the array.[code]
I have 12 empty Movie clips on stage. I want to get the content (jpg's or swf's) for these containers from an array. This is all fine, but I would like the contents to be loaded randomly into one of the 12 containers. The containers load the jpg's, which are preview thumbnails that need to link to the actual larger image plus some text. Loading eveything is OK, but I haven't figured out how to load the content into a random MC... I attached the fla and images.
I'm creating a series of banners for a website. There are 3 so far with more to be made. I have made each banner as a separate swf file.The thing I would like it to do it create a randomly ordered array of the banner swf names and then load the banners in that order. Once the banners have been played or loaded through, I would l simply like it repeat that same order again.I have managed to create an array and play through that array in an ordered loop, but how do I create a random array that will do the same thing?[code]
I have problem with getting a random word from an array and the putting that word to a text field.
I setup the array for my words like this:
Code: // a string of words this.somewords = "wind breeze storm stormy tornado text space"; // convert the string of words into an array of words this.wordList = new Array(); this.wordList = this.somewords.split(" ");
And I want to put randomly these words to a movieclip that I'm attaching to the stage about 50 times.
I'm trying to create a program that creates a random map for a side scrolling cave. So I need to store the roof and the grounds y coordinate into a big array, like 10 000 pieces of wall.
The only way I've gotten it to accept some data into the array is like this but I want something cleaner and something that can go on forever.
How should I format the first 4 lines of code so that the array accepts commands like this and expands for the for loop as needed?
Pattern_Array (created by a random function that pulls from Words_Array and stores the index)Now I want to create another array called Choices_Array that will compare Pattern_ Array to Words_Array and not repeat any of the Pattern_Array index's in the new array.
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.That way It will load the 29 images I have Randomly, with out repeating them and after all 29 appear it will start over again.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.
Code: var images:Array = new Array(); for (var i:Number = 0; i < 29; i++) { images.push("image" + i + ".jpg");[code].....
I'm trying to create a list with an array..My purpose is to put array elements randomly in to the list..But the catch is, I want one array item to assign with 2 list objects..I mean.My arrray is : ["1","2"]And my list is this : "A", "B", "C", "D""A1", "B2", "C2", "D1"
I have 12 empty Movie clips on stage. I want to get the content (jpg's or swf's) for these containers from an array. This is all fine, but I would like the contents to be loaded randomly into one of the 12 containers.The containers load the jpg's, which are preview thumbnails that need to link to the actual larger image plus some text. Loading eveything is OK, but I haven't figured out how to load the content into a random MC
I want something where I click a button, and it replaces words with other synonyms automatically. My thoughts are:
set up array (array1=array2) array1="word1","word2","word3" array2="word1","word2","word3" search text for word in array1 if find in text= word in array1 replace with random word in array2
Would anyone know how to set this up, or point me in the right direction?
I am building a quiz game. I generate a random number. I then compare the number to an array of questions already asked. If a question has been asked, I need to generate another random number and check again if this questions has been asked, until I find a question that has not been asked. I am getting lost in all these loops.
var completedQuestions:Array=new Array(); function getQuestion() { var qnumber=randomNumber(0,numberOfQuestions-1); //I did not include the randomNumber function as this is not the problem
is: I have array={0,1,2,3,4,5,6,7,8,9} and i want from this array unique random pairs.for example: 3,6 nad automaticly 6,3 no repeats.It must give me 10 pairs.for example:
[code]What I'd like to do next is create a subset of 10 randomly chosen (shuffled and unique) questions from the bigger group (say of 21 questions). What is the best way to do this? I'm guessing I'll be using an Array.