Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Random number question

Status
Not open for further replies.

CGann

Programmer
Jan 23, 2004
31
US
Hey all, I'm trying to generate random numbers in multiples of 10 For simplicity's sake I'm only using 10, 20, 30, & 40,(right now). For some reason, my example below only pops between frame 1 and 10.

Any ideas?

/* example */
on (keyPress "1") {
var UpperLimit:Number = 4;
var LowerLimit:Number = 1;
var PlayThisFrame:Number = (Math.floor(Math.random()*(UpperLimit-LowerLimit))+LowerLimit)*10;

gotoAndPlay("valueOf(PlayThisFrame)");

}
 
Thanks Kenneth,
2 questions though...
1. If my code is generating 10,20 or 30, why is it not going to those frames when I press "1"

2. I saw that someone else was trying to do the same thing I'm doing, essentially a flashcard style app. where first pops up the question, then you can click a key to see the answer. This is exactly what I'm trying to do. (I don't want to make a multiple choice quiz. Jus the flashcards.

Bill Watson suggested using a textarea for questions and revealing a text box for the answer. "providing the background is the same then you do not need all these frames....just a question and answer textfield"

Any help on how to do this?
 
I'm getting "Undefined" and it's still popping between frames 1 and 10 only. I'm getting this regardless of whether I use quotes or not in the gotoAndPlay() statement.

var PlayThisFrame:Number = (Math.floor(Math.random(4)))*10;
gotoAndPlay(PlayThisFrame);
trace(PlayThisFrame);


BTW: I really appreciate the help.
 
Code:
var PlayThisFrame:Number = Math.floor((Math.random()*4+1))*10;
trace("PlayThisFrame: "+PlayThisFrame);
this.gotoAndStop(PlayThisFrame);
trace("_currentframe: "+this._currentframe);

Kenneth Kawamoto
 
I'm getting:
PlayThisFrame:
_currentframe: 1
 
still getting...
PlayThisFrame:
_currentframe: 1

 
Genius! Thanks!!!

Any thoughts on my other question: making a flashcard style app. where first pops up the question, then you can click a key to see the answer. (I don't want to make a multiple choice quiz. Just the flashcards.

Bill Watson (in a previous post) suggested using a textarea for questions and revealing a text box for the answer. "providing the background is the same then you do not need all these frames....just a question and answer textfield"

Any thoughts on how to get started?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top