Random quotes

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

You use quotefield.text, so you’re not using it’s variable. Give the textfield the instance name quotefield. Then try this:

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

Forgot to round :wink:

:wink:

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

saweeeeeeeet
thank you very much!!!
both of you

No problem. :stuck_out_tongue:

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

[AS]var index = 1;
next.onPress = function() {
quotefield.text = loadText[“quote”+index++];
}[/AS]
That’s the idea… :stuck_out_tongue:

ahhhh
ok koool
thanks again

You’re welcome. =)