PDA

View Full Version : random quote generator


kamunki
06-11-2005, 01:34 PM
hello there

i'm making a random quote generator for a flash site. i have code:

loadVariablesNum("quotes.txt",0)

stop()
// vars loaded yet?
if (EOF != undefined) {
howMany = Number(howMany);
// pick random number
ran = Math.round(Math.random()*howMany);
// pick quote
quote1 = this["quote"+ran];
} else {
Play ();
}

which works fine for static text. the only thing is i want to fade the quotes in and out and i can't seem to get this code (or any fiddling i've done with it) to work inside a movie.

any help, ideas, support or jokes would be appreciated in this, my hour ov need.

ta muchly

andy kamunki

Billy T
06-11-2005, 03:48 PM
you're loading the vars into level 0 (_root) and I assume you are placing that code inside an mc? therefore you would need to target the var on he main timeline

ie

loadVariablesNum("quotes.txt",0)

stop()
// vars loaded yet?
if (EOF != undefined) {
howMany = Number(_level0.howMany);
// pick random number
ran = Math.round(Math.random()*howMany);
// pick quote
quote1 = _level0["quote"+ran];
} else {
play ();
}


should work...

btw check out the LoadVars object - much better than loadVariables

cheers