PDA

View Full Version : random quotes



Ctrl+Z
August 20th, 2003, 02:19 AM
i'm trying to produce a one frame random quote field
i have a dyn text field "quotebox" with the var of "quotefield"

rn=random(10);
loadText=new loadVars();
loadText.load("quotes.txt");
quotern=["quote"+rn];
loadText.onLoad=function() {
quotefield.text=quotern;
};

that's what i have for code
on the qoutes.txt file i have quote1-quote10 listed

i can get the quotern to display in the text field but can't get the quotes in the text field unless i do this


loadText.onLoad=function() {
quotefield.text=quote10;

add the quote# to the code
which then displays the quote

if anyone has any ideas

thanks

Voetsjoeba
August 20th, 2003, 02:39 AM
You use quotefield.text, so you're not using it's variable. Give the textfield the instance name quotefield. Then try this:


loadText=new loadVars();
loadText.load("quotes.txt");
loadText.onLoad=function() {
rn=random(10);
quotefield.text=this["quote"+Math.floor(Math.round(rn)+1)];
};


Forgot to round ;)

kode
August 20th, 2003, 02:39 AM
http://www.kirupaforum.com/images/search_top.gif (http://www.kirupaforum.com/forums/search.php?s=) ;)

http://www.kirupaforum.com/forums/showthread.php?s=&threadid=29808
http://www.kirupaforum.com/forums/showthread.php?s=&threadid=29045

Ctrl+Z
August 20th, 2003, 03:02 AM
saweeeeeeeet
thank you very much!!!!
both of you

kode
August 20th, 2003, 03:03 AM
No problem. :P

Ctrl+Z
August 20th, 2003, 10:05 PM
ok how about this
what if i wanted to add a next button to the movie

_root.next.onPress=function(){
quotefield.text=this["quote"+Math.floor(Math.round(rn)+1)];
}


is that what i'd use
cause it's not pulling any text at all with this

kode
August 20th, 2003, 10:16 PM
var index = 1;
next.onPress = function() {
quotefield.text = loadText["quote"+index++];
}
That's the idea... :P

Ctrl+Z
August 20th, 2003, 10:22 PM
ahhhh
ok koool
thanks again

kode
August 20th, 2003, 10:24 PM
You're welcome. =)