ActionScript 3.0 :: Using Random Function With While Loop?
Feb 22, 2011
I have a while loop that I need to shuffle the order of my array. This was initially an AS2 code and am trying to convert this over but have come across with an error I don't understand so hoping someone may know what it means. My while loop code is:
Code:
var randomArray = shuffle(orderArray);
function shuffle(toShuffle) { // shuffles an array
[code]......
View 5 Replies
Similar Posts:
Sep 30, 2006
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.
View 3 Replies
Nov 4, 2005
If you place a for loop in a recursive function with the function call within the loop... will the loop finnish or does it stop working untill the last recursion?
View 2 Replies
Nov 2, 2009
I have a variable in a loop that i want to access in a function outside of the loop. However the variable gets deleted when the loop is closed so no longer exists when i call in the function.here is the code; i'm trying to access the variable picHeight from within the scroll function
Code:
pauseTime = 3000;
xmlImages = new XML();
[code].....
View 3 Replies
Jan 7, 2010
I have a movie clip that is preforming a repeating earthquake like effect. What I am attempting to do is have the function pause for a random interval between 2 and 10 seconds before repeating. This is the script I am using for the "earthquake" repeating effect.
onEnterFrame = function(){
mc._x = Math.random()*4;
mc._alpha = Math.random()*50+50;
mc._rotation = Math.random()*2;
}
View 3 Replies
Nov 8, 2011
Learning Action script and programming so I apologize that the solution is simple, I just don't know what it is. What I want to happen is to pass objects through that I want to fall down the screen. I pass the object in through e:Event (which comes from an event listener on the stage) and speed which gets a random number between a high and low value.When I run it, it of course gets a new random number every frame. (because its called by an Event.ENTER_FRAMEHow do I go about this to accomplish my goal?Here is my code:
private function moveIt(e:Event, speed):void
{
if ( e.currentTarget.y <= 400 )
[code]....
View 1 Replies
Aug 27, 2010
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;
[Code].....
View 3 Replies
Jun 14, 2007
Is there a way to make a random 'for loop' like[code]...
i'm pulling stuff from an xml file and would like the loop to display all the entries, but in a random order rather than 0, 1, 2, 3.
if i used the random math function i'm not sure how to tell the loop which entries have been displayed and which have not.
View 5 Replies
Jan 19, 2010
The loops fades a random image, which works great the first time round, if I go to another page and then back the home page (which is where this code is on frame 1) the first image loads but the random image code does not continue. I think it has something to do with nextHolderBool.
var numbers:Array = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20];
var numRemaining:Number;
var randomIndex:Number;
var currNumber:Number;
var nextHolderBool:Number = 1;
[Code] ......
View 7 Replies
Oct 5, 2007
got some code working to duplicate a movieclip, but what I'd really like to do is obviously randomise the movieclip's x position so that it spreads across the stage, rather than stacking in the same position as it is now.
Code:
for (i=1; i<11; i++){
duplicateMovieClip("alien", "alien_new_"+i, 22-10, i);
}
View 4 Replies
Oct 25, 2010
I have a loop that replays on a random timer.Start of loop frame 1:
function pause(){
play();
clearInterval(timer);}[code]...
on the next scene i just want the frame to stop(); forever but it seems to play after waiting for the above designated timed pause.when i remove the code above, stop(); works fine again. How can i get it to work aside my timed pause? anyway to reset it..ive tryed adding clearInterval(Timer); before the stop on scene 3 and its done nothing
View 1 Replies
Dec 23, 2010
I'm trying to generate 5 random numbers within a range. I'm saving these inside an array through the use of a for loop.
[code]...
The result of this is that the 5th slot has a number. The first 4 are "undefined". Why would the last loop work and the others fail?
View 2 Replies
Jul 4, 2009
This code produces a random clip from an array. I need it to loop every 3 seconds. Is this possible?
arr = ["strandA","strandT","strandC","strandG"];
arr.sort(function(){return Math.floor(Math.random()*3)-1});
var clip = arr[0];
this.attachMovie(clip,clip,1,init);
Using Flash MX 2004 V7
View 5 Replies
Jan 19, 2009
I am trying to create a loop that changes the colours of my dynamic vectors inside my sprite however I am not sure if I putt the following var names in the right place in the end of my statement attached or if i need another variable :[code]
View 5 Replies
Jul 5, 2009
This code produces a random clip from an array. I need it to loop every 3 seconds. Is this possible?
[Code]....
View 2 Replies
Mar 4, 2008
I have 10 mc's on my page which I want to load from alpha = 0 to 100, one at a time, but in a random order each time the page is loaded. I have code which uses an array to loop the mc's and I can then load the array into a tween using as2, but I don't know how to randomly create an array, then load these answers into a tween and play them one after another until the loop is complete.
View 1 Replies
Dec 22, 2009
I have 10 mc's on my page which I want to load from alpha = 0 to 100, one at a time, but in a random order each time the page is loaded. I have code which uses an array to loop the mc's and I can then load the array into a tween using as2, but I don't know how to randomly create an array, then load these answers into a tween and play them one after another until the loop is complete.
View 7 Replies
May 2, 2010
I'm trying to have my program select from a random assortment of pictures in the file, and each one is labeled Transition1, Transition2 etc. Each instance of the symbol is named transition1, transition2, though 4. The 4 symbols are in one other symbol with the instance name TransitionImages. For some reason when I run the program it doesn't put the files in the symbols though
stop();
var checkNumberArray:Array=new Array ;
var transitionimageLoader:Loader;
[code].....
View 12 Replies
Aug 9, 2004
I am trying to create a movie clip that loops and on each loop it loads a random little .jpg banner from a directory. The banners are named 0.jpg, 1.jpg and so on, a script on the first frame of the loop saying
Code:
_root.randomnumber = random(_root.bannernumber);
_root.bannerloop.bannerholder.loadMovie("http://www.url.com/directory/"+_root.randomnumber+".jpg");
"bannernumber" is a variable from an external text file specifying how many random numbers to cycle through (how many banners), This works just fine and loads up a new banner after each loop cycle. The problem lies in trying to make each banner go to its own url, I have another external text document with variables "click0=url, click1=url etc" where I want the number in each variable to equal the randomnumber variable in flash, then use an on(release){getURL(urlvariable)} function to have it retrieve the url that is somehow in the url variable. Basically, how would I make the urlvariable be equal to the "click0" variable to get the url of the click0 variable into the getURL function? while having the number in the "click0" variable be equal to the randomnum variable?
View 2 Replies
Jan 7, 2012
I am making a character walk. This code will make him wobble to the right and when thats done it will trigger him to wobble to the left and then call the function again to continue the loop.I can get the loop to work fine by calling the function but how do I STOP the function? Also I want to call it later on. Is there a way to start and stop a function?
function wobble()
{
var ws = .1;
var dis = 1;
[code]....
View 2 Replies
Sep 21, 2011
can i make the animation appear randomly but with time limite ?example:if the random number allow that the animation appear, the animation must stay 3 secondes then dissapear even if the random number is changed before the 3 secondes are finish.also when random number allow that the animation disappear, the animation must stay hidden 3 to 6 secondes randomly but at least it must stay disappeared 3 secondes .
View 5 Replies
Oct 18, 2009
is there any chance someone could give me a function to get a random number between 111 and 666. I need to put this function in a local variable in order to make the result appears in a dynamic text. So I need a simple function in as2 to get that number.
View 2 Replies
Apr 23, 2004
I have the following clipEvent on a movieclip called square:
onClipEvent (enterFrame) {
xmove = (xpos-this._x)/5;
this._x += xmove;
[code].....
View 1 Replies
Mar 3, 2007
I am working on a piece now that will have 10 invisible MC's (1-10) stacked on frame 1 in seperate layers that function like buttons on the main timeline. Each of these mc's will trigger a corresponding mc (A-J) to become visible and play and also start a sound file. This I have all worked out.
What I am writing about is a random function. When 1 triggers A, I would like one of five distinct MC's inside of A to be randomly selected to play, both with sound and with image.
Right now I'm working on the random function with sound, and I'm in need of soome assistance. I'm not sure of my approach, but why I'm stuck in particular now is because ususally when attaching a sound to an MC, when the sound is called it is through the name of the sound rather than the mc name and as I've created a random function I can't very well call the sound name as then it won't be random. Here's what I've got:
sound1 = new Sound(soundHolder1_mc);
sound1.attachSound("chime");
sound2 = new Sound(soundHolder2_mc);
sound2.attachSound("psychic");
[code]...
View 1 Replies
Apr 23, 2004
I have the following clipEvent on a movieclip called square:
onClipEvent (enterFrame) {
xmove = (xpos-this._x)/5;
this._x += xmove;
}
And the following framecode in the same keyframe as square:
_root.square.xpos = Math.round(Math.random()*550);
Now I want to use this information in a function so I can control more than just one clip.
View 1 Replies
Nov 27, 2009
I have a .fla with 5 pics on my timeline and using tween function to roll them from bottom to top, what I need to get those images random from o folder or something.
pics= ["images/pic1.jpg",
"images/pic2.jpg",
"images/pic3.jpg",
"images/pic4.jpg", "images/pic5.jpg"];
[Code] .....
View 15 Replies
Feb 11, 2010
I made a memory game with a tutorial. My knowledge of AS3 is not that good so I have to following question.There is a function like Math.Random to random generate number and put them on stage. I made a memory game and the cards are on the same place every time I play the "movie".I want them to shuffle every time I restart the game. How can I write a good random function in AS3?
View 10 Replies
Mar 17, 2011
I wonder how to make a Math.random() function, or something similar where it chooses a number from 0-9. But as the program progresses, another random variable will appear. That random value is what I want removed from the 0-9 scale. (The other random variable is also from 0-9)
View 4 Replies
Apr 23, 2010
I've designed an interactive quiz that has 10 questions, and for each question 3 possible answers (obviously only one of which is right), however I'd like to add some sound to certain questions and a small video clip. The only issue I'm having, and I've not been able to get my head around. I've loaded all the questions and answers into arrays, and used the random function to display them in a different order each time, and because of this I'm having trouble figuring out how I'll be able to implement the use of sound and video into the project.
I'll post the code so far below as to give a better idea of what I'm trying to do, and what I've done so far.
Frame containing Array function:
[Code].....
View 0 Replies
Sep 4, 2010
i have been trying to write a multi player bingo game, i have got passed all problems, except 1, the random function, the random function works fine with 1 player but when i play the game with more than one user each user will get different numbers and not the same numbers. how would i do it so all users get the same number is there a way where i can shuffle 90 numbers then load them into a movie clip then all users play the movie clip then all users get the same number is this possible or is there a simple way. I have also tried getting random numbers from php mysql but get the same problem,
View 6 Replies