Random Background With Random Text File
I am trying to create a resizable flash file that will act as a background for my html/css website. Within the flash I want to have a script that randomly loads a jpg file from a specific folder on my server as well as a correlating txt file for that background. Here is an example of what I mean.
Say there is a movieclip named "background" and then a dynamic text area named "info" in the lower left-hand corner of the flash movie. I want a script to randomly load a jpg file (say 234.jpg) from a folder named "backgrounds" on the server. I also want it to load the correlating text file into the dynamic text area (234.txt) from a folder named "info". How would I do this and what would the script be?
NOTE: the names of the jpg and txt files would be 1.jpg, 1.txt, 2.jpg, 2.txt, etc.
Thank you for any help you can give!
-- K
FlashKit > Flash Help > Flash ActionScript
Posted on: 03-07-2005, 01:06 PM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Random Background And Text File?
I am trying to create a resizable flash file that will act as a background for my html/css website. Within the flash I want to have a script that randomly loads a jpg file from a specific folder on my server as well as a correlating txt file for that background. Here is an example of what I mean.
Say there is a movieclip named "background" and then a dynamic text area named "info" in the lower left-hand corner of the flash movie. I want a script to randomly load a jpg file (say 234.jpg) from a folder named "backgrounds" on the server. I also want it to load the correlating text file into the dynamic text area (234.txt) from a folder named "info". How would I do this and what would the script be?
NOTE: the names of the jpg and txt files would be 1.jpg, 1.txt, 2.jpg, 2.txt, etc.
Thank you for any help you can give!
-- K
Random Background With Correlating Text File
I am trying to create a resizable flash file that will act as a background for my html/css website. Within the flash I want to have a script that randomly loads a jpg file from a specific folder on my server as well as a correlating txt file for that background. Here is an example of what I mean.
Say there is a movieclip named "background" and then a dynamic text area named "info" in the lower left-hand corner of the flash movie. I want a script to randomly load a jpg file (say 234.jpg) from a folder named "backgrounds" on the server. I also want it to load the correlating text file into the dynamic text area (234.txt) from a folder named "info". How would I do this and what would the script be?
NOTE: the names of the jpg and txt files would be 1.jpg, 1.txt, 2.jpg, 2.txt, etc.
Thank you for any help you can give!
-- K
Random Background And Txt File
I am trying to create a resizable flash file that will act as a background for my html/css website. Within the flash I want to have a script that randomly loads a jpg file from a specific folder on my server as well as a correlating txt file for that background. Here is an example of what I mean.
Say there is a movieclip named "background" and then a dynamic text area named "info" in the lower left-hand corner of the flash movie. I want a script to randomly load a jpg file (say 234.jpg) from a folder named "backgrounds" on the server. I also want it to load the correlating text file into the dynamic text area (234.txt) from a folder named "info". How would I do this and what would the script be?
NOTE: the names of the jpg and txt files would be 1.jpg, 1.txt, 2.jpg, 2.txt, etc.
Thank you for any help you can give!
-- K
Random Lines Of Text From Txt File
Hello again,
I have a slight problem I hope you guys can help with. Basically I have a txt file with lines of text and was wondering if there is a way to load in randomly one line of text at a time and to keep this cycle going?
Hopefully I have explained this well enough!
Thanks again
How Do I Load A Random Text From A .txt File
What I want to do is create a quiz with a random question to load, I want the questions to be stored in a .txt file and have four answers to choose from, and in Flash, want to be able to load these questions in a random order, and have it so they can select an answer.
All help would be great!
Thanks!
Jeff
Random Quotes From Text File
Hello,
I have read different post from these forum, on getting random quotes from text file displayed in the flash movie.
I have txt file called quotes containing the following
quote1=easily the best sound i've heard on the web - steve"e2=blahblahblah"e3=qywyyettrtt"e 4=This is 4
and have this code on frame 1
loadVariableNum("quotes.txt", 0);
and this on 2
ran= math.round(math.random()*10+1);
myDynamicTextfield=eval("quote"+ran);
and a dynamic text box with the instance name of 'quote' but does not seem to be working, do not even get error.
Please help me if you can, just need it for random quote each time swf page is loaded!
Thanks in advance
Marcus
Random Line From Text File?
Great help so far, hopefully someone here can help me with this as well!
Is it possible for actionscript 2 to choose a random line from a text file and then display it somehow? Dynamic Text for example?
Load Variables From Random Text File In Set? HELP
I need to be able to_ Load variables from random text file in a given a set._ I am using the newest flash version (fx, mx??) on Mac OS X
heres what I was emailed
"needs:_
1. we'd like this game to load numbers dynamically from a given range
of numbers rather than from a textfile._ If all the numeric variables
loaded randomly from say a range of 1 to 10 for level 1 then how can
you program to make the answer for the game?_
2. , we have to devise a
way to keep track of the number of times a user chooses the bucket and
make the bucket work that many times._ So if you click 30 times
really fast on the bucket, it will probably only work 2 or 3 times as
it has to play an animation after a click._ The bucket becomes
inactive while in animation so how do we tell it to keep working
based on clicks?_
3._ keeping track of correct answers._ So this may be a way off but
we need to keep track of the wins by a user when they enter into the game._ keep track of these wins over the course of the whole game, or based on each user. "
can anyone help me or give me code for how to do any of this? I am rather lost and don't know where to begin- please help! I am still a beginner and would love some step by step how to's thank you!
Adding Random Text From File To Preloader
I need to add a text field to my preloader. I want the text to be a random quote taken from a text file i will prepare (40-50 quotes). I'm fairly new to all this so detailed step by step directions would be appreciated.
Thanks
RAnDoM Load From Txt File To Text Field
I'd like to have an input text field with an instance name, lets call it "rantext" and I'd like for this frame to load a random text from a .txt file everytime this frame is loaded.
Is there something simple for this?
Thanks in advance!
Random External Text File Error?
I have a script that loads a random image/jpg file as well as the correlating text file with info in it. The script looks at another text file to get the "max random" number and then randomizes the number of the photo/info file. The random image loading works great, but I can't get the text file to load. What is wrong with this code?
// create a clip to hold the image
this.createEmptyMovieClip("imageHolder", 2);
// selecting random images
myArray = new Array();
// loads text document containing number of images
loadVarsText = new LoadVars();
loadVarsText.load("info/number.txt");
//assign a function which fires when the data is loaded:
loadVarsText.onLoad = function(success) {
if (success) {
trace("done loading");
// only after the data finishes loading, you-ll be able to use it
for (i = 1; i <= this.var1; i++) {
myArray.push('photo' + i);
}
randNumber = random (myArray.length);
// load the image.
loadVariables("info/" + myArray[randNumber] + ".txt", 0);
imageHolder.loadMovie("backgrounds/" + myArray[randNumber] + ".jpg");
} else {
trace("not loaded");
}
};
____________________________
I have a folder named "info" that has two text files in it (photo1.txt and photo2.txt). I have a dynamic text field on the stage of the movie with a value of "info" in the var: box. The contents of the text files look like this:
&info=Author: first name/n
Title: Rust Sample/n
Time: 4:45pm/n
Date: 01/04/04/n
- Why would this not be working?
Thanks,
-- K
Random External Text File Error
I have a script that loads a random image/jpg file as well as the correlating text file with info in it. The script looks at another text file to get the "max random" number and then randomizes the number of the photo/info file. The random image loading works great, but I can't get the text file to load. What is wrong with this code?
// create a clip to hold the image
this.createEmptyMovieClip("imageHolder", 2);
// selecting random images
myArray = new Array();
// loads text document containing number of images
loadVarsText = new LoadVars();
loadVarsText.load("info/number.txt");
//assign a function which fires when the data is loaded:
loadVarsText.onLoad = function(success) {
if (success) {
trace("done loading");
// only after the data finishes loading, you-ll be able to use it
for (i = 1; i <= this.var1; i++) {
myArray.push('photo' + i);
}
randNumber = random (myArray.length);
// load the image.
loadVariables("info/" + myArray[randNumber] + ".txt", 0);
imageHolder.loadMovie("backgrounds/" + myArray[randNumber] + ".jpg");
} else {
trace("not loaded");
}
};
____________________________
I have a folder named "info" that has two text files in it (photo1.txt and photo2.txt). I have a dynamic text field on the stage of the movie with a value of "info" in the var: box. The contents of the text files look like this:
&info=Author: first name/n
Title: Rust Sample/n
Time: 4:45pm/n
Date: 01/04/04/n
- Why would this not be working?
Thanks,
-- K
Random Quotes From External Text File
I've been trying to figure out how to load a random quote from an external text file which looks like this quote1=blah blah blah"e2=blah blah blah...and so on up till about 10 different quotes. I just want to know how I would go about randomly loading a selected quote? I'm using MX 2004.
Heres the code I tried to use but it only gave me an undefined:
Code:
ranQuote = new LoadVars();
ranQuote.onLoad = function(success){
if (success) {
RanNum = Math.ceil(Math.random()*10);
ran = ["quote"+RanNum];
quote_txt.htmlText = this.ran
}
else {
quote_txt.htmlText = "Text failed to load.";
}
}
ranQuote.load("Quotes.txt");
stop();
Any help or a tutorial pointing me in the right direction, or even a completely different way of doing it perhaps using XML, would be greatly appreciated.
Cheers,
AhrJay
Loading A Random .txt File Into A Dynamic Text Box
I have ten files called quote1.txt, quote2.txt, quote3.txt etc....
What code would I need to randomly load one of these files into a dynamic text box in my movie called 'quotetext'?
Any help is much appreciated
[CS3] Loading A Random Word From Text File
I need some help with loading a random word from a text file. I have a text file that has 250 words in it and reads like this.
Code:
word0=ace
word1=act
word2=ape
...
I need to either load every word into and array or load a single random word from the list, which ever is easiest.
I tried this code but to no avail.
Code:
var wordArray = new Array();
wordData = new LoadVars();
wordData.onLoad = function() {
randomNumber = Math.floor (Math.random() * 249);
trace(randomNumber);
currentWord = "word" + randomNumber;
randomWord = this.currentWord;
trace(randomWord);
}
wordData.load("lvl1_words.txt");
As well as this,
Code:
var wordArray = new Array();
wordData = new LoadVars();
wordData.onLoad = function() {
for(i=0; i<150; i++) {
currentWord = "word" + i;
wordArray[i] = this.currentWord
}
}
wordData.load("lvl1_words.txt");
All help is much appreciated, I can change the prefix of the words in lvl1_words.txt as I have written a C++ program that takes the words from an original file and appends a prefix.
Thanks.
Fading Random Ordered Text From External Text File
Newb to flash. Watching various tutorials trying to come up to speed.
What I would like to create is a small flash ap that displays text in a randowm order from an external text file. I wantot create a small text box in the sidebar of a web page where customer references are displayed in random order. (so users dont see the same ones each time) I want the text to fade in and out as the next text item is displayed.
Can someone kindly point me to a resource that is close to helping to create this? Or; is flash the wrong way to go for this?
Curt
Edited: 12/02/2006 at 12:22:31 PM by cwrig
Display Random Text Message From A Text File
How do i display a Random text message in Flash from a text file?
I want to do something like a "quote of the day" thing
so i need a random quote in the flash movie everytime
users call up the htm page in the browser.
Please help.
Loading Flash Variables From Text File And Using In Random
In flash 5 I loaded variables from a text file and i can display them in dynamic text fields. (varibles are integers), but I can't do math with them or use in the Random() function. Flash recognises their values as 0. Does any one know how I could do this, thanks.
Loading Text File - Picking Random Vars
I'm trying to make a simple quiz for my students. Since I don't want to keep updating the FLA file it will load data from a text file. I hope to move up to MySQL in the future, but for now I am stuck with text files.
Basically there are three boxes on the screen. The top box has a word like "interesting", the bottom two boxes are choices such as "-er" and "more __ than". Students would pick the box that is correct for the top word, here it would be "more ___ than".
I can import data from a text file into one box, and I can shuffle things around randomly, but I am having trouble randomly picking something from the file. The file is in the standard format of:
&topWord0 = Interesting&
&topWord1 = Fast&
Eventually it will get much bigger and include other data such as the top word being a word and students have to choose Verb or Adj. It could also be a T/F question. For now I am trying to take baby steps since I am new to ActionScript (though I have done some ColdFusion and PHP).
Thanks
Html Formatting Of Random Text Messages Loaded From TXT File
I am loading various text messages from a text file randomly using flash and php. I want to format the text a certain way and want to pass in html instead of just dynamic text. The php code is parsing out each line seperately and loading a random message. (1 line = 1 message)
Any ideas on how to set this up? thanks!
Random Text Message From Text File
i have a text file full of quotes.
i want to be able to generate a random quote in flash from that text file, how would i go about doin this??
Please help
Random Background
i have built a script to load a differenct background picture in random order. the script follows: -
SelectionBGArray = new Array();
SelectionBGArray[0] = "3";
SelectionBGArray[1] = "4";
SelectionBGTotal = SelectionBGArray.Length;
randomBG = SelectionBGArray[random(SelectionBGTotal)];
gotoAndStop (randomBG);
i have different background pictures on frame 3 and 4. the random function returns either 3 or 4 and thus gotoAndStop (3 or 4). i'm not very happy with this and it is very buggy. does anyone know better ways to do this? i would like to put all of the background pictures in one frame and manipulate the x and y coordinates as the .swf file loads. but i think setproperty method only works with on (release) event.
Random Background-mc's?
On my stage I have four buttons, and a background-mc too.
Let's say I want to have three background mc's, and want to random these mc's, so that they change every time I enter the site.
Is there a really easy way to do this? I'm using F4 and Mac.
Thanks ;D
coala
Random Background
I'm trying to design a custom tetris game for a local cricket club that I play for. I want to have a cricket background behind the main game. I want the background picture to change everytime the player starts a new game. How do I tell flash to load a new pic at the start of a new game????
Lee
Random Background
I'm new here so...Hello!
I only really know the basics of Flash, I don't have much knowledge of Action Scripting but I'm keen to learn! So here goes with the first of many (probably very dumb) questions;
If I were to create say 5 different background graphics or images how would I go about being able to have one of them randomly load to the background of my flash page when somebody enters the site?
Hopefully it's nothing too difficult!
Thanks in advance,
Sarah.
Random Background
My client wants to use an image as the background but wants 3 different backgrounds that will be selected randomly at the time of loading. She is trying to avoid having the same background every time. Is this possible?
Random Background
hello.. i was just wondering the correct coding to use to create a randomized background.. im trying to find tutorials.. but no luck.. where the movie clip for the background is in one movie clip.. but i really didnt want it that the site would just be going through the same actual animation.. i wanted to change colour randomly from the ones i set.. and animate.. instead of just running the movie clip.. or making about 200 frames.. where once it gets to one from it stops.. then calls another.
thats actually the question im more so wanting to.. with actionscripting the code to make it count maybe a min or 2.. then go to a randomized frame label. hopefully this is possible. i havent actually touched flash for a while.. been pushed into using visual basic by my boss.. so ya.. if anyone can help.. im using flash mx 2004
Random Background
Fox,
i am very new to flash n need some urgent help,
working on a project where i need 2 things,
1. randomly changing background everytime i open that flash file
2. how to call an swf or a flash file in another flash file n play the animation with the background of the file in which i am calling the other fla.
e.g.
i want "movie X" to be played inside the "movie Y" with the background of the "movie y" and all the components too.
please help, a little urgent
thanks
Random Background
Im looking for a way of loading a random image from xml and resize it to 1280x960 . All the examples i have are for loading multiple thumbnails .
My xml is below , can anyone show me an example .
Quote:
<item type="Wallpaper">
<img><![CDATA[Wallpaper/name.jpg]]></img>
</item>
Random Background
For mostely all of you it's will appair as a stupid question but am searching for a soultion since couple houer whitout figure it
My problem is am trying at to load into my swf a random background each time a visitor come into the site. i read couple tutorial and put some idea from them tougeder.
I called my diferent background (in propriety panel) ''background1'' to ''background6'' and they are occurence of symbole 84 to symbole 89
so here my code
ActionScript Code:
// random background donne une valeur aleatoire entre Background1,2,3,4,5 Nom d'occurence ActBg1,2,3,4,5
K = Math.ceil(Math.random()*5);
attachMovie("Background"+K, "ActBg"+K, 1);
// displayit
"Background"+K = visible.root_;
am not sure of evrething in this code and am realy sorry to bother you whit that basic stuff Any kind of help would be appreciate thx
Random Background
Hi there
I was wondering how I can add a random background to my flash site. This script should generate a random background everytime someone views my site...
Exactly like this site: http://www.exopolis.com/site/
Visit it 2-3 times to see how it does it.
SWF Random Background
Hi,
Got a little problem that I hope all you talented Flash pros could help me with.
I’m creating a Flash site with a random, allow scale, swf background. On top of that background I want my navigation menu, this should not scale with the background.
I used the KIRUPA tutorial to create the random background and it works fine, the problem is that the top navigation menu doesn’t stay the same size….it scales with the background. Think I have to use Fscommand() somehow?
If you go to www.puma.com, you can see exactly what I’m looking for.
Here is the Kirupa tutorial: http://www.kirupa.com/developer/mx/loadingrandombackground.htm
Thanks!
Random Background From XML
hey guys, its been a while since ive been on here. but i need some help.
i am making a full screen flash site and need a random pic as the background but it loaded from an xml file so the client can control it.
i know you guys know how to do this im not looking for new code!!
thanks in advance this place is awesome
Random Background From XML
hey guys, maybe i posted this in the wrong place earlier.
i need help bad, in a bind and need a background of a full window flash movie to be a random image with data loaded from an xml file.
any code or tips you have will be greatly appreciated i need help!!
Random Background
Hi there
I was wondering how I can add a random background to my flash site. This script should generate a random background everytime someone views my site...
Exactly like this site: http://www.exopolis.com/site/
Visit it 2-3 times to see how it does it.
SWF Random Background
Hi,
Got a little problem that I hope all you talented Flash pros could help me with.
I’m creating a Flash site with a random, allow scale, swf background. On top of that background I want my navigation menu, this should not scale with the background.
I used the KIRUPA tutorial to create the random background and it works fine, the problem is that the top navigation menu doesn’t stay the same size….it scales with the background. Think I have to use Fscommand() somehow?
If you go to www.puma.com, you can see exactly what I’m looking for.
Here is the Kirupa tutorial: http://www.kirupa.com/developer/mx/loadingrandombackground.htm
Thanks!
Random Background Help
I followed this tutorial.
http://www.kirupa.com/developer/mx/l...background.htm
It is a step by step guide on how to load a random background image. It loads a .swf into a movieclip on your main timeline. I did everything right, but the thing is, is that I am trying to load the image into a movieclip thats inside of another movieclip. For example it says to load the image into the movie "location." I need to load it into "background" then "location."
The gist of the code says.
choice = Math.round(Math.random()*5);
switch (choice) {
case 0 :
location.loadMovie("image0.swf");
break;
now if i need to put it into another movieclip dont i do this?
choice = Math.round(Math.random()*5);
switch (choice) {
case 0 :
_root.background.location.loadMovie("image0.swf");
break;
Well I tried that and a bunch of other options, but it didn't work. Someone please help me. Even another link to some better tutorial will help. Anything. Thanks.
Jonathan
Random Background/animation ?
Hi folks,
i've got an question. I want to make an menu for my webpage and so i will creat some animation (example: a dot which follows a line) but i will make it five or six of this animations so that the menu dosn't will be boring. ok now i've got an question: is there a way to make this animations randomize? in one of my flash books i found a script to shange the background after every start (its the code for the background):
Go to an play (Random (_totalframes))
Here the background are on one frame per movie (as background). Is there a way to write an script to randomize some different screens and that there will be a random brake after one screent with the differnt animations (i thinks it's boring too if a animation will change after one ends). And how can i realize this random brake.
I hope someone can help me
Random Background Movieclips?
Hi,
I would like to have at least two different background movieclips - so that the background changes every time I enter my flash site.
Is this difficult? How can I do this?
Thanks // coala
Random Background Images
Hello,
I am using Flash v5.0 and I can't figure out how to make a random background image appear each time someone accesses my webpage...if anyone could help me it would be greatly appreciated!
Cheers,
Macohead
Random Color In Background
I have a Website built in MX with two basic colors in the background. I want to add a script that changes the two background colors on site randomly. The catch is that I have certian colors that I want displayed together. For example, blue and green are used together then pink and yellow and orange and blue. How could these colors switch based on every visit to the site, but remember it can't just be any random color it has to come from a set that I specify (blue/green, pink/yellow, orange/blue, etc.).
Thanks
Random Background Color
i googled this but a lot of sites talk about "background color"...
anyone know how to give the stage a random bg color out of a choice of say 4 or 4 defined colors?
a nice addition would be being able to get the webpage its sitting in to appear the same color, via php (or alternatively let the php get the random color and pass it to flash...)
any ideas?
EDIT: just realised the bg color of the movie is of course defined by the webpage its sitting in... so php can handle that.
but how about if i want to pass the rgb value that was chosen by the php into the movie to be used by symbols...?
Help Random Background Image
Hello guys, i need a hand please!!
Im trying to do a site but with a random backround.. add like 5 different images and make the background fit in the resolution of all computers and every minute make them change with an effect!
please if someone knows how can i do this that is not creating a movie clip symbol with animation cause that wont be random and wont fit in all resolutions.
Thank you guys!!
roth
How To Create A Random Background?
I am trying to create a Xmas crad, which atomatically loads one out of 10 backgrounds randomly. Is there any easy way to do that?
Thanks a lot!
Background Random Appearance
Hi
I am designing a flash area for a website, and what I want is for my small image of a cloud I made to pass across the stage (120 X 400) from right to left, across the stage. However, I would like the cloud to come in at random places, have random speeds, and be random sizes. I have no idea how to approach this. Any ideas would be really helpful
Thanks
[F8] Operation: Random Background?
How can a random background function be made?
I mean Im trying - very hard - to make a game like the game "Tanks", currently Im stuck with programming on the background generating.
By that I mean EASY ways to generate random backgrounds which 'ent too impossible.
Now I dont want to generate the Y position for 400 movieclips (1pixel wide) and then getting the proximity and recheck, reposition. Thank you
THx for any help I could get.
<Tongxn>
|