I'm trying to figure out problems with global variables and functions. My script has a set of variables it calls on to check if a user has typed in a username, or if they have anything typed in at all. It then compares the username to the database (not done yet). However, I've noticed that for some reason, the variables do not work outside the functions they are declared in, and global variables refuse to work as well. The only way the script works is if the variables are non-global, and inside the "checker" function, but I need to reference some of them outside the function.

Code:
stop();
_global.checktest = username_test.text;
_global.userbase = checktest.length;
_global.newbase = userbase-1;
numberofcards = 0;
cardnumber.text = numberofcards;
/// "Check" Button, linked to Username_test.text ///
checker.onRelease = function() {

	if (_global.newbase == 0) {
		errortxt.text = "Please enter your username.";
	} else {
		/// Check if the username entered is in the database ///
		var php_process:LoadVars = new LoadVars();
		var post_variable:LoadVars = new LoadVars();
		post_variable.string = checktest;
		post_variable.sendAndLoad("control.php",php_process,"POST");
		trace(_global.newbase);
	}
	php_process.onLoad = function(success:Boolean) {
		if (success) {
			errortxt.text = php_process.result;
		} else {
			errortxt.text = "Error connecting to server.";
		}
		/// End Check Code ///
		trace(newbase);
	};
};
/// The Next Button ///
pageonenext.onRelease = function() {
	if (_global.newbase == 0) {
		errortxt.text = "I'm sorry, please enter your Username.";
	} else {
		gotoAndStop("pagetwo");
		trace(_global.checktest);
	}
};

function theTimer() {
	errortxt.text = "";
}
var testing = setInterval(theTimer, 9000);