Action Script
// first we create the objects
login_lv = new LoadVars();
//now we create the function that will happen when this object recieves data
login_lv.onLoad = function() {
//check to see if the users info is correct
if (this.userInfo == "true") {
gotoAndStop("Success");
userName.text = login_txt.text;
} else {
//if the users info was not correct, trace an error, and clean the text fields
trace("Invalid data");
login_txt.text = "";
password_txt.text = "";
}
};
//the function for the login button
_root.authenticate_btn.onPress = function() {
// an error will occur if the user didn't enter a login name
if (login_txt.text.length<1) {
trace("please provide a login name");
// an error will occur if the password is not the right length
} else if (password_txt.text.length<5) {
trace("invalid password");
// and clean out the password
password_txt.text = "";
} else {
// this is if everything is fine to send
// we will store the user information as properties of the LoadVars object
login_lv.username = login_txt.text;
login_lv.password = password_txt.text;
// now we send the data, and wait to recieve something back
login_lv.sendAndLoad("http://localhost/login.asp", login_lv, "POST");
}
};
newlogin_lv = new LoadVars();
newlogin_lv.onLoad = function() {
//check to see if the users info is created
if (this.newuserinfo == "true") {
trace("New User Created");
userName.text = login_txt.text;
} else {
//if the users info was not created, trace an error, and clean the text fields
trace("Error Creating User");
login_txt.text = "";
password_txt.text = "";
}
};
//the function for the new user button
_root.newuser_btn.onPress = function() {
// an error will occur if the user didn't enter a login name
if (login_txt.text.length<1) {
trace("enter a new login name");
// an error will occur if the password is not the right length
} else if (password_txt.text.length<1) {
trace("enter a new password");
// and clean out the password
password_txt.text = "";
} else {
// this is if everything is fine to send
// we will store the user information as properties of the LoadVars object
newlogin_lv.username = login_txt.text;
newlogin_lv.password = password_txt.text;
// now we send the data, and wait to recieve something back
newlogin_lv.sendAndLoad("http://localhost/newuser.asp", newlogin_lv, "POST");
}
};
stop();