Actionscript
- Started
- Last post
- 11 Responses
- ScottTheRobot
I have a flash countries+capitals quiz where the user must type in the name of the country and capital in a text box.
As it stands, the user must type in the name of the countries and capitals perfectly (case and spelling). I'd like to have it account for variations in case and variations in spelling.
I've been searching with no luck. Any suggestions/links/code?
- tomkat0
make an array for the answers?
- Mimio0
You could make a pseudo database of a multi dimensional array that you can loop through and check when the person enters a country. Where the initial element in each nested array is your preferred spelling and all the subsequent ones are the variations in spelling/case etc.
- Solid0
For variations in spelling you'll probably need a DB.
For case variations:
var str = "United States";
str.toLowerCase();// returns "united states"
trace (str);
- ScottTheRobot0
i'm trying to get away from having to list every possible variation in spelling...
(btw - i just figured out the case problem. I just need to figure out spelling)
Is there some kind of spell checking algorithm?
- Anarchitect0
Mimio's right.
a multidimentional array with each index correspondign to a unique letter makes the search loop easier/faster.
- Solid0
sorry, that should be:
// returns "united state"
trace (str.toLowerCase());In other words, whatever the user enters, convert to lowercase for comparison purposes.
- ScottTheRobot0
yeah, thanks Solid - i just found the toLowerCase() thing!
- Solid0
Are you saying you wish to ALLOW mis-spelled entries, or you want to DISCARD mis-spelled entries?
'Allowing' requires you to 'guess' what the user has entered - seems rather difficult to do.
'Discarding' would be much easier :D
- ScottTheRobot0
Yeah- I am wanting to allow users to type: 'washington dc' and 'Washington, DC' and 'washingtn, D.C.' and a myriad of other similar things - yet still have the program record it as a correct answer.
- Solid0
Interesting - don't know the answer to that, but would def. be interested to know how you solve the problem ;D
- ScottTheRobot0
I just may have to end up typing all those variations...
there are too many damn countries in this world.