ActionScript 3.0 :: Make A Random Number Generator?
May 26, 2010I wanna know how I can make a random number generator.I want the random number to "spawn" in a text field.
View 3 RepliesI wanna know how I can make a random number generator.I want the random number to "spawn" in a text field.
View 3 RepliesActionScript Code:
var numbers:Array = [];
var newNb:Number;
var max:Number = 81;
[code]...
Code:
BTN_generate.onRelease = function(){
textDisplay1 = random (6) +1;
[code]......
im sure its an easy one:
var tstArray:Array = new Array(1,2,3);
for (var a:uint=0; a<tstArray.length; a++)
{
var x:Number = Math.floor((Math.random()*tstArray[a]));
[Code]...
the idea is that the player clicks a button to look out the window and then one of 4 options will present themselves at random, he will also be charged 5 energy points for the priviledge.
[Code].....
I am running a sweepstakes like thing and want my users to all be able to load the page and have the exact same countdown and number generator running. I tried this in AS3 but each user caches their own swf file and gets a different result from the random number generator, and the as3 countdown is a few seconds off from each user. How would I go about making a countdown that is the exact same for each user looking at it at the same time and then a random number generator where every user will see the same result it gives? Is it even possible?
Sorry I wasnt clear on this. I would like to have it where the viewers could see the number being generated when the timer runs out. Kind of like watching the lotto on TV. Again, not sure if this is possible. I have looked around, I know as3, some php, and some javascript. I have given up on doing this in flash.
ok, so i have this movie. i have three scenes in it. and i wanna make it so the first scene randomly selects a number so it can jump to either scene 2 or 3. so everytime it loads the page it will go to either one of those randomly. i can easily do this buy loading external swfs and getting it to work, however jumping to a random scene in the movie doesn't seem to work right. here's my code, anyone know what i'm doing wrong? am i missing something simple?
Num = Math.random();
Num = Math.round(Num);
if (Num == 0) {
[code].....
I am just making a random number generator and I have got the random numbers going using this script.
Code:
onClipEvent (load) {
go = true;
}[code]....
The only problem is that the numbers are way to fast I'd like them to be 1/2 if not 3/4 the speed that they are. how can I do that?
i have three scenes in it. and i wanna make it so the first scene randomly selects a number so it can jump to either scene 2 or 3. so everytime it loads the page it will go to either one of those randomly. i can easily do this buy loading external swfs and getting it to work, however jumping to a random scene in the movie doesn't seem to work right.[code]
View 7 RepliesI'm totally new to ActionScript 3 and just trying some very simple things to try to understand how it works in Flash CS5. I have no-one mentoring me so these forums are my first port of call. I wanted to create a simple random number generator. Very simple. Click on a button (first_50) that displays a random number in a text box (main_balls.text) set to Classic/Dynamic. The script I have is as follows:
first_50.addEventListener(MouseEvent.CLICK, firstFiftyGenerator);
function firstFiftyGenerator(limit:Number):Number
{
var randomNumber:Number = Math.floor(Math.random()*(limit+1));
return randomNumber;
main_balls.text = String(firstFiftyGenerator(50));
I get no errors in the compiler and my button works in runtime. I just don't get a number in my text box when I click on it.
So, I'm just starting a bigger AS3 project. I'm still learning AS3, transitioning from AS2 and I keep getting caught up on dumb stuff. I'm creating two variables to store a maximum and minimum value for a random number generator. Here's my code.
[Code]...
How to make a random password generator using only action script??
View 2 Replieshow to make a random password generator using only action script??
View 2 Repliesi want to make random number between 1 to 10 without repeat number twice or more i use this function to make random
function getRandomNumber(min:Number, max:Number):Number
{
var randomNumber:Number = Math.round(Math.random() * (max - min) + min);
return randomNumber;
}
getRandomNumber(1, 10);
I have code that I got off line that will create a random number in the output tab. I put together an if else statement, however I can not figure out what how to call the random number into the if else statement. My last try was calling "n," However that did not work. I have a bit of the code that I am working with. I am giving only the first 3 but there are 13 in total, but as they are all the same just going to different frames I thought that it was not necessary to show them all.
function randRange(min:Number, max:Number):Number {
var randomNum:Number = Math.floor(Math.random() * (max - min + 1)) + min;
return randomNum;
[code]...
If there is an easier way to get the same thing I am open. I just want it to start on a specific random frame (13 of them).
I am not sure how to make a random number between two numbers. I want to make a random number between 1000 and 3000
View 9 RepliesIm looking for some action script that will let me take one symbol or movie clip and let me produce it over and over with different sizes.For example, bubbles comming up a wine glass
View 4 RepliesI am currently putting together a simple game where people have to pass my tests to join a club. At the end I would like them to be given a unique name. I imagine this could be done if I make 3 lists of 50 words, and right a piece of code that randomly selects one word from each list to create a unique combination almost every time. I am using actionscript 2 because I am fairly novice and this is about as complicated as my code is going to be, but is this to bigger job for action script 2?
View 4 RepliesI've basically finished this project, but there are some feature I'd like to add which are giving me trouble. Heres the jist of the flaIt takes data from a txt file and uses split() to put that data into an array (a list of phrases). Then it randomly chooses one of these phrases and displayes it in a text field, then it repeats this every 5 seconds.What I am trying to add are these two things:1) do not repeat array value until all have been used once2) alpha fade in and out of each phrase, the AS of which is basic, but I am not sure where to put the code and set it up in this case.Im just confused on where to place and exactly how the write the code for these additional elements
View 5 RepliesI've been looking at the Loading Random Background Imageexcept for the fact that it does not seem to work with ActionScript 3.0 . It looks as if the problem lies in the "choice" property. Could someone suggest a solution, or alternative method to have three random images?Code as it is now:
choice = Math.round(Math.random()*3);
switch (choice) {
case 0 :
[code]....
As a teacher I am looking to create a random name generator to use with my classes. I don't know much but I am willing to learn.I want my random name generator to be able to load class lists from an external file - I want the random name generator to be able to recognise the time and load the pre-defined class for that time of day. I think this will work best if the day and time were listed above each class list in the file. I will also look to add a basic action button which generates a new name when pressed. I have seen some posts referring to creating a random number generator and then link this to a text list but I think I am trying to do something a bit more different.
View 2 RepliesThe tutorial for the Random Color Generator is for Flash 5. When I attempt to edit in Flash MX 2004 it does not work. I'm guessing there is something simple that needs to be changed. I tried to search the forum for an answer, but I didn't find one.
View 6 RepliesI was trying to work out how to make flash select a random number, but between 0 and 5 .
View 8 RepliesI am creating a whack a mole game in Flash CS5 AS 3.I have nine instances of the same movie clip that I am trying to make appear randomly as the "mole". So far I have the following script:
var girlarray:Array = new Array();
girlarray[0] = instanceofhole1;
girlarray[1] = instanceofhole2;[code]............
I have created some code that creates a blue circle of random size on the stage, and startmoving it in a random direction, at a random speed.
But I'd like to create this as a static class, so that I can just import into a banner and make multiple instances appear at a time, but my limited knowledge doesn't allow me to
Here is my code:
Code:
var child:Shape = new Shape()
var childSpeedX:Number = Math.random()
var childSpeedY:Number = Math.random()
var childDirectionX:Number = Math.random()
[Code]....
I want to create a random name generator from a list of certain names seems simple but i'm not really sure [code]...
View 2 RepliesI'm working on a project that involves choosing a random image from a directory, taking it, and displaying it.This works (roughly, not very nicely nor perfectly...) but the main problem is that the picture are too big for the stage, and I want to eliminate the need to resize every picture manually. I would like flash to do it for me. So I've been looking at other people's work and tutorials and have made this script:[code]Also -- can anyone tell me why it sometimes will display the same image twice or three times in a row?I can't see anything wrong with my script as to why it repeats an image!The variable that is in charge of that is "stored".To the best of my knowledge 'stored' is set to 999, which should force flash to run the conditions and pick a random number. Then, when it runs again, it should check if they are already equal, correct?
View 3 RepliesI have read the tut about Random Color Generator. I want that it keep changing collors. It starts already when the flash movie is loaded but it stand stil after 1 color made.
View 4 RepliesI have a code that randomly generates a random sentence:[code]...Now on every word, I have a sound clip that I want to play, but how would I code it? I dont know I would I would assign a sound to a word or how to incorporate it into the coding above
PHP Code:
if(name "example"){mysound = new Sound();mysound.attachSound("example");mysound.start();}
[code].....
I want to make a theme generator that works like a random Exquisite Corpse. Imagine you write out out different "types" of ideas, categorize them, and place them in several cookie tins or boxes� a color palette tin, a media tin, a subject matter tin, etc. If you pull one entry from each tin, together they make a new string/list. This list would then be the project I work on.
For example: A [dark colored] [album art design] that incorporates [chickens] and [skulls].A [light colored] [t-shirt design] that incorporates [silohuettes of people] and [boomboxes]A [specific predetermined hexidecimal palette] [illustration] of [chains] and [unicorns] This is what I know: It would be nice to have the amount of subject matter or color choices come at "random" (a number between 1 and 10?).Since these lists will continually be updated, I'm assuming XML functionality is a must.
Dynamic text fields and the ability to dynamically create them (if more than one subject matter is randomly chosen) will be used.These aforementioned idea lists will be stored in arrays. A random function will spit out an index number (its range will equal to the amount of items in the array) and that index number will put it's subsequent item into the dynamic text field(s) on the stage.Hitting the space bar or clicking a button will clear the fields and randomly populate them or create new ones if more than one subject matter or color palette is randomly chosen. I seriously have no idea how to go about doing this, but it seems like a really rad idea and something I desperately need.