[CS3] Weighted Random Text Generator
I've seen a few threads on this but they seem to be buried pretty deep in the archives. I'd like to build a random text selection script, one that is weighted so that certain text shows up more often. Using AS2 to do so, what would be the best way? This'll be used as a Sponsorship bar mostly on a website. Text would be weighted like this: Sponsor texts - 1, showing up most of the time. Website announcements, sales, etc, weighted 2, showing up more often. Based on previous threads, this:
Code: RanNum = Math.ceil(Math.random()*Number(this.quoteCount)); ran = this["quote"+RanNum]; quote_txt.text = ran; seems like it'd be the best way - but how would you make it weighted?
FlashKit > Flash Help > Flash Newbies
Posted on: 08-05-2008, 01:12 PM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
AS3 - Gaussian / Weighted Random Distribution
Hi all.
I'm trying to create a weighted random distribution, and can't figure out how to go about it. basically I want to create a starry sky, where most of the stars are in the middle of the screen. by making the y random, like:
Code:
star.y =Math.random()*_mc.stage.stageHeight;
I just get an even distribution on the Y axis. What I really want is to have most of the stars near _mc.stage.stageHeight/2.
Anyone has a good idea of how to accomplish?
thanks!
Random Text Generator
Hi.
I want to make a code verification form. Those forms that generate an image which you have to read and type down the code in it.
I want to have AS generate a random set of letters and numbers in an unselectable textField. That will be the generated bitmap (not a bitmap actually, but... ). I also want that randomly generated set of letters and numbers to be written down in a variable so that i can compare the variable with the input field of the user to test if it is ok.
Does anyone know how to randomly generate that?
Thanks a lot.
Random Text Generator
hi all. i posted this over at the http://laco.wz.cz/
but i think these forums are move activite, so no one bite my head off for doing this. and i hope they dont mind.
BUT.
http://laco.wz.cz/tween/?page=examples
if you go here.. the first example (navigation like yugop.com v4 (without lmctween)) is what my question is about, the fla download is next to it.
when you put ur mouse over a button, there is a niffty little random text effect before it goes into the proper name.
how do i do this on something totaly new!
Quote:
function startTextAnimation(oldId,newId){
//duration = 20
//printf("//",newId,items_arr[newId].smallText);
items_arr[oldId].mc.label = items_arr[oldId].smallText
//items_arr[newId].mc.label = items_arr[newId].smallText +":"+ items_arr[newId].text
var strlen = items_arr[newId].text.length
textanim_mc.onEnterFrame = function(){
var rndstr = "";
//
if ((textanimDuration - textanimTime) < strlen){
rndstr += items_arr[newId].text.substr(0, strlen - (textanimDuration - textanimTime))
for (var i = 0; i<(textanimDuration - textanimTime); i++){
rndstr+= String.fromCharCode(random(50) + 20)
}
} else {
for (var i = 0; i<strlen; i++){
rndstr+= String.fromCharCode(random(50) + 20)
}
}
items_arr[newId].mc.label = items_arr[newId].smallText +":"+ rndstr
//
if (textanimTime++ > textanimDuration){
items_arr[newId].mc.label = items_arr[newId].smallText +":"+ items_arr[newId].text
textanimTime = 0
delete this.onEnterFrame
}
}
i think it has something to do with this, but not sure.
i hope someone can help, and i hope im not doing anything illegal by posting here.
thanks.
Random Text Generator
Hi.
I want to make a code verification form. Those forms that generate an image which you have to read and type down the code in it.
I want to have AS generate a random set of letters and numbers in an unselectable textField. That will be the generated bitmap (not a bitmap actually, but... ). I also want that randomly generated set of letters and numbers to be written down in a variable so that i can compare the variable with the input field of the user to test if it is ok.
Does anyone know how to randomly generate that?
Thanks a lot.
Random Text Generator
hi all. i posted this over at the http://laco.wz.cz/
but i think these forums are move activite, so no one bite my head off for doing this. and i hope they dont mind.
BUT.
http://laco.wz.cz/tween/?page=examples
if you go here.. the first example (navigation like yugop.com v4 (without lmctween)) is what my question is about, the fla download is next to it.
when you put ur mouse over a button, there is a niffty little random text effect before it goes into the proper name.
how do i do this on something totaly new!
Quote:
function startTextAnimation(oldId,newId){
//duration = 20
//printf("//",newId,items_arr[newId].smallText);
items_arr[oldId].mc.label = items_arr[oldId].smallText
//items_arr[newId].mc.label = items_arr[newId].smallText +":"+ items_arr[newId].text
var strlen = items_arr[newId].text.length
textanim_mc.onEnterFrame = function(){
var rndstr = "";
//
if ((textanimDuration - textanimTime) < strlen){
rndstr += items_arr[newId].text.substr(0, strlen - (textanimDuration - textanimTime))
for (var i = 0; i<(textanimDuration - textanimTime); i++){
rndstr+= String.fromCharCode(random(50) + 20)
}
} else {
for (var i = 0; i<strlen; i++){
rndstr+= String.fromCharCode(random(50) + 20)
}
}
items_arr[newId].mc.label = items_arr[newId].smallText +":"+ rndstr
//
if (textanimTime++ > textanimDuration){
items_arr[newId].mc.label = items_arr[newId].smallText +":"+ items_arr[newId].text
textanimTime = 0
delete this.onEnterFrame
}
}
i think it has something to do with this, but not sure.
i hope someone can help, and i hope im not doing anything illegal by posting here.
thanks.
Random Generator
I'm looking for a simple random word or phrase generator. I've seen the password generators and I've also tried building the "Tip of the Day Generator" by Eddie Carroll in the tutorials with no success.
I want to be able to create a large list of words, that when a simple mouse button is rolled over or pressed, can display only one of the words in the list randomly.
The Tip of the Day Generator was exactly what I was looking for but I wasn't able to get it to work on the tutorial page or when I download it.
Thanks in advance for any help.
Mike
Random Generator
Hey all, I'm just woundering if someone can help me with a random generator for questions...I know the random function is involved but do I need to use arrays? I'm not sure but thanks to all that will help me.
Azrael
Random Generator
Hey all I need help with a random question generator where I explained what I want from this other forum I asked. here's the link
http://www.actionscript.org/forums/s...threadid=19800
thanks much help would be apreciated.
Azrael
Random Name Generator
I am trying to make a random name generator but i cannot find any tutorials anywhere any help would be appreciated!!!
Random Generator
Hi...
How do I script a random generator?
What I want to do is design a button that goes to either frame "label1", or frame "label2", frame "label3" (...) randomly when clicked.
Any ideas?
Thanks for your support!
Random Name Generator...
Hey everybody, I'm new to Flash and Actionscripting but I'm very keen as I'm embarking on a project I've wanted to do for a long time and intend on doing everything I can to bring it to reality
However, the very first task I set myself I have already bumped into a hurdle I cannot seem to surmount
What I want to do is write a script that generates a random number (between 0 and 5 for now), then uses that random number to define a first name field within Flash. In addition I want to have that data saved in a database or something for future access within the program, but I'd better take baby steps first I think :P
After scouring the web looking in help files and tutorials, I came up with the following code:
randomnumbergen = Math.round(Math.random()*5);
ramdomnumber = randomnumbergen;
if (randomnumber==0){
trace("Jesus");
}
if (randomnumber==1){
trace("Luke");
}
if (randomnumber==2){
trace ("Daniel");
}
if (randomnumber==3){
trace ("Rudiger");
}
if (randomnumber==4){
trace ("Henry");
}
if (randomnumber==5){
trace ("Thomas");
}
This code is apparently big free, but I must be missing something because when I try to test run the code in a Flash document, it returns absolutely nothing.. =/
I'd love to get the ball rolling and have this work for me, but I just can't seem to get it working so I'll probably look like noob #1 now haha but could anyone help me out and set me straight?
Cheers
Luke
Random Generator
Hello, I would like to know how can I randomly generate phrase so that every time I click an object a different message will appear.
Random Generator
Hello All,
I have put together a random generator that is supposed to display to a text box a phrase one at a time when a button is pressed. I have gotten to the point where it does display but it displays all 10 at one time. How do I get it to only display one at a time randomly? any ideas?
ActionScript 3.0
Code:
stop();
//create the array
var dataArray = new Array();
var randValue = Math.random();
function theProgram (event:MouseEvent):void {
//data in the array that is supposed to feed randomly to the val text box.
dataArray[0] = "one";
dataArray[1] = "two";
dataArray[2] = "three";
dataArray[3] = "four";
dataArray[4] = "five";
dataArray[5] = "six";
dataArray[6] = "seven";
dataArray[7] = "eight";
dataArray[8] = "nine";
dataArray[9] = "ten";
//puts random phrase into val text box on UI.
val.text = dataArray.toString();
}
//button name
start_button.addEventListener(MouseEvent.CLICK, theProgram);
Any Way To Set Up A Random Flv Generator?
The concept is pretty simple I think, I just can't get my brain around how get it to work. Basically all I want to do is have my swf randomly pull in an flv with the swf loads. Same concept as a random image generator if you will - so each time you go to the site, it will pull a different flv in. I think there has to be a way to do this via xml, but as I said, I'm having brain issues trying to bring it to fruition. Any help would be greatly appreciated.
Any Way To Set Up A Random Flv Generator?
The concept is pretty simple I think, I just can't get my brain around how get it to work. Basically all I want to do is have my swf randomly pull in an flv with the swf loads. Same concept as a random image generator if you will - so each time you go to the site, it will pull a different flv in. I think there has to be a way to do this via xml, but as I said, I'm having brain issues trying to bring it to fruition. Any help would be greatly appreciated.
Random Word Generator
Im making a random sentence generator and im having problems with the random command. I have a movie clip for each word within the sentance(wordOne) with stop frames. within those I have I single moveclip with the spoken word. I need to be able to gotoAndPlay a random frame from frame 2 to 6. how do I di this with the random or Math.Random? at the moment its only from frame 1 – 6!
Can anyone help with the code and an explanation of what the code is doing please
Random Image Generator
A little help plz, I want to insert a random image loader, one that randomly displays an image within an swf from external jpgs. Is this possible in Flash 5? if so how?
http://octagon.uk.tt
Random Generator With ComboBox
I am new to flash mx, reasonably competent in flash 5.
i would like to use a combobox with 6 different words.
i have added a data value of 1-6
i want a button which,once pressed, will randomly generate one of the
labels in the boxes.
in the button I have placed the following code to generate the random number but i do not know how to get this to control the label in the combo box.
on (release) {
RandomButton.onRelease = function() {
RND = Random (5);
};
}
please advise.
Random Quote Generator
i am looking to make a magic 8 ball in flash and i would like some help in finding a tutorial that will explain how to create random quotes. if anybody knows of a tutorial that explains this can you please post the link here. thanx
Random Image Generator
I need to create a movie or movieclip that will randomly place an image or symbol on the stage (for example, I might create five images or symbols which would be randomly selected when the user clicked a button).
Altrnatively, I could also imagine a scenario in which one of a set number of movies is randomly loaded into a level when the user clicked a button.
Any suggestons?
Thanks!
Random Image Generator
Need some help finding a tutorial on generating a random image in 3 different places... I got the image to load in a movie clip but for some reason when I try to make it random it stops placing the image in the empty MC I have set up for it.
here's the code I'm using...
Code:
randImg = random(12)+1;
onClipEvent (enterFrame) {
this.attachMovie("pic"+randImg, "picture1", 1);
}
Random Image Generator
Does anyone know where to find script for a random image generator that pulls the images from an external source?
Random Quote Generator?
I am trying to make a basic random quote gerator where you push a button and a line of text shows up. Each time you push the button a new line of text appears. I searched the tutes section and the board as well but couldn't really make sense of what was there. can anyone give me a clear way to do this simply. I have attached the file I am trying to make work.
Random Number Generator
Hello Everyone.
This may sound odd, but I need help developing a script that will do the following:
1. When a person first views a movie, 4 random 5-digit numbers get generated.
2. It needs to be possible to assign each one of these random numbers a variable name.
3. Finally, although the 5-digit numbers are random, the first 2 digits must always be "99"
Thanks very much for your time
IGD
Random # Generator, If/Then (simple)
Not really a Flash newbie, but I am an Actionscript newbie.
Our site has a flash file that scrolls between images of five news "stories". It plays a sequence right now. I've been tasked with randomizing the entry point so that it starts at a new story on each visit (just a random 1-5). I think I have the idea of how to do it, just not the syntax.
I have this on the last slide of the preloader:
rn = random(5);
if (rn=2)
{
gotoAndPlay('Scene 2');
}
if (rn=3)
{
gotoAndPlay('Scene 3');
}
if (rn=4)
{
gotoAndPlay('Scene 4');
}
if (rn=5)
{
gotoAndPlay('Scene 5');
}
else
{
gotoAndPlay(1);
}
I'm probably missing something silly... or maybe I just have no idea. Right now, it just always goes ahead and plays story #1.
Thanks!
Random Number Generator
does anybody know how i might make a random number generator that will create a number or numbers in a selected range at the click of a button?
thanks in advance
Random Number Generator
Hi all, hope you all had a good Christmas ...
Can anybody help ? I want to create a random number between 1 and 10 but am not sure of the actionscript to use.
The Random Number doesn't have to be shown anywhere on the screen, it just has to be there if you know what I mean.
[F8] Communicating Random Generator
Given: five identical movieclips that hold five frames.
Now, I want each movieclip to randomly display a frame, however, every frame should only be displayed ONCE.
==> In case the first movieclip randomly displays FRAME3,
the other four movieclips can only "choose" between randomly
displaying FRAME1, FRAME2, FRAME4 and FRAME5.
Is this possible?
Thanks for your inspiration!
me.
Random Scene Generator
Hi there,
I am in the process of creating a short flash animation where the user will click a button to reveal an image.
What I want is for that button to randomly choose the image.
If I create say 4 or 5 outcomes to the scenario, how can I make the button randomly choose which image to show.
Any help is much appreciated, and I send my grateful thanks in advance.
All the best for now,
Stuart
Random Number Generator
Hi,
I'm pretty new to flash, and was trying to figure out how to create a random number generator from scratch. I've been trying to learn a bit of action scripting here and there, but I don't know if it's my level of understanding that just won't get it.
I have the following...
1)Input Text Field (to type in the max number that should be randomized to)
Example: 60 (Number from 1 through 60 will be chosen)
2) Dynamic Text Field (to show what random number has been generated).
3) Button (to shuffle the numbers)
Any assistance on how I should go about doing this would be great. I appreciate any help you can give me. Thanks.
Random Lottery Generator
Hey all,
First time on this what looks like a great site. I've only dabbled with bits of actionscript for basic of functions but now I need to create something with a bit more intelligence. This is going to seem really easy for most of you but any code help would be very much appreciated.
- What I'm trying to do is create a lottery machine where the user enters 6 different numbers (ranging from 1-49). Those numbers are stored.
- The user then presses a button to start the lottery machine, and the code then picks randomly 6 numbers itself and displays them.
- A message is displayed telling the user how many balls they have matched.
All I know is that is sometime to do with math.random.
Regards,
Chrissy
Random Path Generator
If I have a ball for example and I have point A and point B (point A being the center of the ball) and I want the ball to go from A to B each time from different paths, how is this possible?? I need it to create paths for this movement.
Random Number Generator
Does anyone have the actionscript that will make flash generate random numbers when a button is clicked and the numbers are displayed within a dynamic text box???
Thanks
Random Image Generator
hi,
I have built a photo gallery which loads a new image from an array when the user hits the next button
this.pathToPics = "images/";
this.pArray = ["sign035.gif", "sign036.gif", "sign037.gif", "sign038.gif", "sign039.gif", "sign040.gif", "sign041.gif", "sign042.gif", "sign043.gif", "sign044.gif"];
this.fadeSpeed = 20;
Does anyone know how I can get the images to load in a random order when the user hits next?
Thanks in advance for any help!
Random Integer Generator?
I'm looking for a function that spits out random integers between 0 and [ArrayName].length so that I can select random array indexes. Does AS3 have one? Alternatively, anyone have a good formula for converting the decimal Math.random()?
Random Number Generator
Hi, I'm trying to create 6 different random numbers between 1 and 49 but can't seem to get my head around the code. I'm using Math.random 6 separate times to generate 6 numbers but am struggling with how to ensure each number is different.
Can anyone offer any advice?
Rob
Random Generator Of Scenes
hi,
is there anybody that could tell me how to randomise some scenes by clicking a button. i have made loads of exercises on different scene pages and i need to access them via a random generator. this is urgent as its for my degree at uni.
thank you
Nilpa
Random Quote Generator
Hi All,
I have created a database to contain a quote and a name and created ASP to randomly generate a different quote and name each time. After looking around in the forum, I used "noCache" to refresh the quote each time. It does that everytime I hit the refresh button or reload the page. I, however, wanted to have a series of quotes randomize on while a user remains on the page and can't seem to find a solution to do that. Does anyone have a suggestion or a solution? Many thanks appreciated!
ActionScript Code:
onClipEvent(load)
{
// loads in quotes
loadVariables ("getquotes.asp?id=1&noCache="+Math.floor(random(1000000)/random(1000)), this);
}
onClipEvent(data)
{
// field1 = quote
field1.text = quote;
// field2 = name
field2.text = name;
}
Random Number Generator
This should be pretty easy:
I want to make a button that, when clicked, tells a movie clip to jump to a random frame. For my purposes say frames 1-7.
Code:
on(release){
myClip.gotoAndStop((randomNumberGeneratorThingy(6)+1))
}
Can someone finish this up correctly?
Better Random Number Generator?
hey guys, i wrote a flash mp3 player and i'm trying to make it randomly play mp3s from the playlist.
i started off using "Math.round(Math.random()*numtracks)" to pick the next track, but i noticed the randomness was pretty poor... like 50% of the time it start with the same track, and it kept repeating songs or played only a few songs for the majority of the time.
so then i put that in a while loop and kept track of the last 2 songs, so that at least i could guarantee that it wouldn't play a song that it just recently played -
newcurrtrack = Math.round(Math.random()*numtracks);
while ( newcurrtrack == lasttrack || newcurrtrack == currtrack )
{
newcurrtrack = Math.round(Math.random()*numtracks);
}
lasttrack = currtrack;
currtrack = newcurrtrack;
that made a huge improvement, but it still could be better. anyone have any ideas on how to make a... more random... random number?
Help For Random Number Generator?
hi there can anyone how to make simple random number generator for slot machine , formula for chances in probability , or simple random number generator for slot machine , thanks :)
Random Percentage Generator
Hi-
i don't know actionscripting, just checking if Flash would even be the proper application to obtain my desired result:
I'm setting a grid of squares, say 100x100, and would like to generate a random pattern according to the following rules: 30% (or any percentage I desire) of the grid is a specific color, and another 20% (or any percentage I desire) is another color, with the remaining squares white.
Would actionscripting be the way to go? Is there an even simpler way for me to create this w/o learning a new app?
Thanks.
Random Image/Swf Generator
So I am in a comic book club and i am making the website for it. We make our own comic books of course and i would like for every time you change the page that the image of one our characters comes up. Basically i have a big wallpaper in the bg, and there is a big speak bubble in the middle close to middle). I want the characters to slide upwards and stop near the point of the bubble (where the mouth usually is duh). And every time you click a page the Text bubble (UI loader) changes the text and i would like a random character to show up. If its possible it would be cool if it was a random swf so that way i can have the characters slide and the logo of the appropriate comic would pop up too)
If anyone could help me with this it would be helpful.
Random Question Generator Help Please
hi, im new to this flash game, im trying to create a random question generator. i have a set of questions that all need to be displayed but in random order. ive put them in an array, and have got them to appear randomly on screen, the problem is, i only want them to appear once within the loop, so i can add up the scores at the end, i cant seem to find any tutorials for this specific method.
Random Phrase Generator
(Flash MX)
I'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 fla
It 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 once
2) 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. Help would be appreciated!
SWF
FLA
I've also attached the .txt file that populates the array.
Peace
Random Number Generator
I have searched the forum, and have not found the answer to this question:
I need to generate a 6 digit random number from Flash MX, then pass that number as a variable to an .asp page. I know how to pass the variable, but I'm not sure how to generate the number, then set it as a variable...
Thanks in advance,
Rev
Random Color Generator For AS 2.0 Or 3.0
Hi,
I've come across the random color generator which appears to have been written back in Flash 5 when you were still allowed to give instances numbers instead of only letters. Hence I'm having problems making this script work in CS3 when I want to add more movie clips (and thus type in additional instance names - that have to be numbers). Anybody? Any? Ideas?
Thank you,
Stefan
http://www.kirupa.com/developer/flash5/randomcolor.htm
Random Question Generator HELP
ok here's the lowdown..
I basically need to a have a flash file that brings in random questions from a text file on the server and has a "yes" or "no" button at the bottom to answer the questions.
so heres the code i got from kirupa:
ranQuote = new LoadVars();
ranQuote.onLoad = function(success) {
if (success) {
RanNum = Math.ceil(Math.random()*5);
ran = this["quote"+RanNum];
quote_txt.text = ran;
}
else {
quote_txt.text = "The text failed to load due to an error";
}
}
ranQuote.load("Quotes.txt");
stop();
------
My problem now lies in determining 1) which question was brought in randomly and 2) this will obviously allow me to redirect the user to a different page (for each different Q&A)
so if for example the 2 questions are: are you man? if clicked yes, will take them to a picture of a man or are you a woman, if clicked yes, will take them to a picture of a woman..
sounds simple i know, but im a n00b to the code
If you know the answer to this, you are my hero and guru.
PLEASE! i need the answer by monday to present to a client.
Would really appreciate some help guys!
Thanks!
|