Skip to main content
Venian
Inspiring
November 5, 2007
Answered

Random text generator

  • November 5, 2007
  • 1 reply
  • 426 views
Hi.

I want to make a code verification form. Those forms that generate an image which you have to read and type down the code in it.
I want to have AS generate a random set of letters and numbers in an unselectable textField. That will be the generated bitmap (not a bitmap actually, but... ). I also want that randomly generated set of letters and numbers to be written down in a variable so that i can compare the variable with the input field of the user to test if it is ok.

Does anyone know how to randomly generate that?

Thanks a lot.
This topic has been closed for replies.
Correct answer kglad
:

1 reply

kglad
Community Expert
Community Expert
November 5, 2007
place the characters that you want to use in an array and then use the Math.random() method to generate an random index - ie, Math.floor(array.length*Math.random()) - from that array.
Venian
VenianAuthor
Inspiring
November 5, 2007
I must be ashamed but i've never worked with arrays. What do i target and how do i transfer the value to a variable or text field?
kglad
Community Expert
kgladCommunity ExpertCorrect answer
Community Expert
November 5, 2007
: