THE ADDRESS BOOK
fyi - you can make the password field have *** instead of showing the typed letters by:
1. select that textbox
2. under properties, paragraph, behaviors - select password
The code:
import flash.events.MouseEvent;
var loginName:Array = ["Renee", "Donald", "Ross"];
var myPassword:Array = ["booyah", "master", "Higgins"];
var theFirstNames:Array = ["Ross", "Joe", "Renee", "Donald", "Brian", "Annelie"];
var theLastNames:Array = ["Higgins", "La Ponza", "Rose-Perry", "Quitangon", "Lee", "Zambrana"];
var theEmailAddress: Array = ["ai@aiiemail", "asdfas", "reneeroseperry@yahoo.com", "awesome@blah", "Zemail@email.com", "me@me.com"];
var theBirthdate: Array = [ "Mystery", "April 21", "November 16", "May 1", "February 20", "January 12" ];
/* var theSearchResult:Number = theFirstNames.indexOf("Joe");
trace(theLastNames[theSearchResult]);
//index of - it searches the array and returnes the index number of the searched position */
//first_txt.text = "";
search_btn.addEventListener(MouseEvent.CLICK, onClick);
function onClick(event:MouseEvent):void {
var theSearchText:String = first_txt.text; //storing the typed text into a variable when the button is clicked
//use that first name var to find the index number
var theSearchResult:Number = theFirstNames.indexOf(theSearchText) //state the array you want to search (theFirstNames)
//then use that index number to match it to the last name index number
// at this point if you trace(theSearchResult) it gives you the index number of the theSearchText
var theLastName:String = theLastNames[theSearchResult]
var theEmail:String = theEmailAddress[theSearchResult]
var theDob:String = theBirthdate[theSearchResult]
//display that index number (lastname)
last_txt.text = theLastName
email_txt.text = theEmail
dob_txt.text = theDob
}
add_btn.addEventListener (MouseEvent.CLICK, addName);
function addName (event:MouseEvent):void {
//trace("poop");
var addName:String = addName_txt.text;
//trace(addName);
theFirstNames.push(addName);
//trace(theFirstNames);
var addLast:String = addLast_txt.text;
theLastNames.push(addLast);
trace(theFirstNames);
trace(theLastNames);
var addEmail:String = addEmail_txt.text;
theEmailAddress.push(addEmail);
trace(theEmailAddress);
var addDob:String = addDob_txt.text;
theBirthdate.push(addDob);
}
login_btn.addEventListener (MouseEvent.CLICK, submitIT);
function submitIT(event:MouseEvent):void {
// search the array for the user name, get that position
var enteredName:String = login_txt.text;
var searchedLoginName:Number = loginName.indexOf(enteredName)
var correctPass:String = myPassword[searchedLoginName]
// if not found
//else is found
//store the index number in variable
//use that index number to look up the password in the pwarray
//stored to var correctPass
if ( passwordField_txt.text ==correctPass) {
//trace("yay");
greyBox.visible = false;
var welcomeName:String = login_txt.text;
login_txt.text = "";
passwordField_txt.text = "";
response_txt.text = "Welcome " + welcomeName + ", I deserve an A!";
}
else {
//trace("hell no")
greyBox.visible =true;
login_txt.text = "";
passwordField_txt.text = "";
response_txt.text = "You Suck, try again.";
}
}
No comments:
Post a Comment