以下是相关的AS3代码:
public function processLogin ():void {
var phpVars:URLVariables = new URLVariables();
var phpFileRequest:URLRequest = new URLRequest("php/controlpanel.php");
phpFileRequest.method = URLRequestMethod.POST;
phpFileRequest.data = phpVars;
var phpLoader:URLLoader = new URLLoader();
phpLoader.dataFormat = URLLoaderDataFormat.VARIABLES;
phpLoader.addEventListener(Event.COMPLETE, showResult);
phpVars.systemCall = "checkLogin";
phpVars.username = username.text;
phpVars.password = password.text;
phpLoader.load(phpFileRequest);
if(result_text.text == "Welcome")
{
gotoscenetwo();
}
else{
stop();
}
}
public function showResult (event:Event):void {
result_text.autoSize = TextFieldAutoSize.RIGHT;
result_text.text = "" + event.target.data.systemResult;
}
和我的PHP代码:
include_once“connect.php”;
$ username = $ _POST ['username']; $ password = $ _POST ['password'];
if($ _POST ['systemCall'] ==“checkLogin”){
$ sql =“SELECT * FROM users WHERE username ='$ username'AND password ='$ password'”;
$ query = mysql_query($ sql);
$ login_counter = mysql_num_rows($ query);
if($ login_counter> 0){
while($ data = mysql_fetch_array($ query)){
$ username = $ data [“username”];
print“systemResult = Welcome”;
}
}其他{
print“systemResult =登录详细信息与我们的记录不匹配。”;
}
}
这是我的迷你项目。我的问题是如果as3在MySQL数据库中找到匹配的记录,我的gotoscenetwo()
函数就开始工作了。谢谢你的帮助。
答案 0 :(得分:0)
如果 需要在 showResult 的函数内