PDA

View Full Version : simple next button



Ctrl+Z
September 28th, 2003, 09:46 PM
on my site I have a dyn text field that displays quotes.
1st it loads a random quote and then you can hit 'next' to view other quotes.
I have a dyn text field that display what # quote you're seeing.
when you hit the next button it displays nothing in the quote field but will show the # 1 in the quote # field. you hit next again and it will show you the #1 quote in the quote field and says it's #2.
here is the AS for the loading of the quotes and the next button:

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


and here's the link to the quote movie:
http://ctrlzproduction.com/flash/d-75HLK/quotes1.html

I can't see what I'm missing that's making it wrong

thanks in advance

APDesign
September 29th, 2003, 02:00 AM
m=random(138)+1; might work? I did'nt look at your code very much and without the .fla I'm a little confused, but it is common that you don't want the random number to start at 0. Ok, looking over the code a little more I see you add the 1 in this line


quotefield.text=this["quote"+Math.floor(Math.round(rn)+1)];


P.S. you should use the AS command when you post action script, a lot easier to read. (use start bracket AS endbracket to start, and start bracket /AS end bracket to complete it)