Hello Ronald,
Thank you for your response.
You mean to say, should we check FMS or remoting stuff ?
We have saved your FLA in flash 8 format and exported for AS 2. These are the only changes. We commented FMS related code and tested for plain remoting. It works perfectly without hitch.
BTW, all FMS samples given by MM(currently Adobe) are working fine.
I am pasting the changed code here
stop();
/*
function login(){
//Check if the username have at least 4 chars
if (username.text.length<4){
message.text = "Please enter username (minimun 4 characters)";
return;
}
//Check if the username have at least 4 chars
if (password.text.length<4){
message.text = "Please enter password, minimun 4 characters";
return;
}
//Show a waiting message
message.text = "Checking user/pass. Please wait";
//Disable the push button
loginButton.setEnabled = false
// Create a connection Object
client_nc = new NetConnection();
// Handle status message
client_nc.onStatus = function(infoObject){
trace("on status of client");
if (infoObject.code == "NetConnection.Connect.Rejected")
{
message.text = "Wrong username or password. Try again";
loginButton.setEnabled = true
}
if (infoObject.code == "NetConnection.Connect.Failed")
{
message.text = "Connection to server failed. Try again";
loginButton.setEnabled = true
}
if (infoObject.code == "NetConnection.Connect.Success")
{
gotoAndStop(2)
}
}
// Connect to the application
client_nc.connect("rtmp:/login", username.text, password.text);
}
loginButton.setClickHandler("login");
/*/
////////////////////////////////////////////////////////////////////////////////////
//// If you want to check first your method using only Remoting (Whitout FlashCom)
//// comment all above lines and uncomment below lines. Set the "path to your gateway.php"
/////////////////////////////////////////////////////////////////////////////////////
import mx.remoting.*;
//import mx.remoting.debug.NetDebug
stop();
function login(){
NetServices.setDefaultGatewayUrl("http://localhost/testFMS/login/gateway.php");
var gatewayConnection = NetServices.createGatewayConnection();
var service = gatewayConnection.getService("login", this);
//call the server function
var callServer = service.authenticate(username.text, password.text);
//handle server response
this.authenticate_Result = function(result){
if(result)
{
gotoAndStop(2)
}
else
{
trace("check username or password");
}
}
//Manage possible errors
this.authenticate_Status = function(status){
trace("Error")
}
}
loginButton.setClickHandler("login");
The above code works fine. We have made no change to your PHP files except changing gateway file's include path and database credentials in inc_sql.php.
Gateway.php is as follow
<?php
//default gateway
include "amfphp/Gateway.php";
$gateway = new Gateway();
$gateway->setBaseClassPath("./services/");
$gateway->service();
?>
inc_sql.php is as follows
<?php
########################
# SQL parameters
########################
// Here You must define a user, password and host to match your needs.
// Debug flag outputs full error messages when installing
define ("USERNAME","root");
define ("PASSWORD","swapnil");
define ("HOSTNAME","localhost");
define ("DATABASE","Login");
define ("DEBUG", "true");
?>
The above code is absolutely working fine.
Here is the code for main.asc file
// ActionScript Communications Document
//NetServices class library
load("netservices.asc");
application.onConnect = function(clientObj, username, password)
{
trace("this is in on connect");
//application.rejectConnection(clientObj);
//Modify the path to match your needs !!!!!
NetServices.setDefaultGatewayUrl("http://localhost/testFMS/login/gateway.php");
var gatewayConnection = NetServices.createGatewayConnection();
for(var i in gatewayConnection)
{
trace(i + " = " + gatewayConnection[i]);
}
var service = gatewayConnection.getService("login", this);
//call the server function
var callServer = service.authenticate(username, password);
//handle server response
this.authenticate_Result = function(result){
manageConnection(clientObj, result);
}
//Manage possible errors
this.authenticate_Status = function(status){
manageConnection(clientObj, false);
}
}
manageConnection = function(clientObj, isAuthenticated){
if(isAuthenticated){
application.acceptConnection(clientObj);
} else application.rejectConnection(clientObj);
}
We have just put some trace statements which definitely will not do any harm for sure.
I hope this helps to clarify my settings and my code.
Thanks and best regards
Swapnil