|
-
I probably don't want to have to create a variable for every character, whether or not it is just 26 of them for just the uppercase alphabet I'm using. It seems like it would be a ton of code to reset those variables.
Since its limited to ten characters, and I have an 'Apply' button basically, couldn't I just compare each character to every other character and if at least one matches another just return a message stating the entry is invalid? Oh, I just realized I need to enforce a minimum character count of ten for this to work too. So maybe I need to see if AS3 has any functions like PHP does that allow you to take apart strings and determine string length and such.
EDIT:
Haha! Nevermind then! All my OOP experience came in handy and I just used this which works like a charm...
Code:
function Decrypt(Event:MouseEvent):void
{
var KeyString:String = InputBox.text.toString();
var com1:Number = 0;
var com2:Number = 0;
if(KeyString.length < 10)
{
ResponseBox.text = "INVALID KEY! ERROR NO. 001";
return;
}
else
myLoop: for(com2 = 0; com2 <= 10; com2++)
{
if((KeyString.charAt(com1)) == (KeyString.charAt(com2)) && ((com1 < 10) && (com2 < 10) && (com1 != com2)))
{
ResponseBox.text = "INVALID KEY! ERROR NO. 002";
break myLoop;
}
else
{
if(com2 == 10)
{
com2 = 0;
com1++;
}
if(com1 == 10)
{
BeginDecryption();
break myLoop;
}
}
}
}
Last edited by Rajada; 04-20-2011 at 04:00 PM.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|