Random word generator help needed

Okay, in games like wheel of fortune and hangman, the word/phrase is chosen randomly from a database for players to guess. Everytime a different word is randomly chosen to be displayed, the number of alphabets for that word is different also.

Now, can anyone explain to me how to make this work in actionscript? I just cant think of the way to code it so that the number of boxes (which represents letters that are hidden) will be automatically generated and displayed according to the word/phrase chosen.

It’s better if there’s a sample code to show how this works. Any flash experts out there being able to explain to me?