new scene after login success AS3
hi guys,
i'm new actionscript have trouble in understanding code. tried many ways go new scene after login successful sadly failed. followed 1 of tutorials on login part..it works , i'm happy wif it..but currently, displays success message. instead, wanna go new scene don't know how. i'll post code below. hope u can ..i have dateline project. thanks!
[actionscript]
package actions {
import flash.display.movieclip;
import flash.events.*;
import flash.net.*;
import flash.text.*;
public class main extends movieclip {
public function main ():void {
submit_button.buttonmode = true;
submit_button.addeventlistener(mouseevent.mouse_down, checklogin);
username.text = "";
password.text = "";
}
public function checklogin (e:mouseevent):void {
if (username.text == "" || password.text == "") {
if (username.text == "") {
username.text = "enter username";
}
if (password.text == "") {
password.text = "enter password";
}
} else {
processlogin();
}
}
public function processlogin ():void {
var phpvars:urlvariables = new urlvariables();
var phpfilerequest:urlrequest = new urlrequest("login.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);
}
public function showresult (event:event):void {
result_text.autosize = textfieldautosize.left;
result_text.text = "" + event.target.data.systemresult;
}
}
}
[php]
<?php
include_once "dbconnect.php";
$username = $_post['username']; //variables flash
$password = $_post['password'];
if ($_post['systemcall'] == "checklogin") {
$sql = "select * users username='$username' , password='$password'";
$query = mysql_query($sql);
$login_counter = mysql_num_rows($query);
if ($login_counter > 0) {
print "systemresult=welcome $username!";
} else {
print "systemresult=invalid user!";
}
}
?>
you want check value returns , use decide whether go next scene or not.
public function showresult (event:event):void {
result_text.autosize = textfieldautosize.left;
result_text.text = "" + event.target.data.systemresult;
if(string(result_text.text).indexof("welcome") == 0) {
gotoandplay(1, "scenename");
}
}
what first line checks see if word welcome @ start of whatever in textfield (starts @ index 0). if does, issues command move frame/scene
More discussions in ActionScript 3
adobe
Comments
Post a Comment