| Updated on | |
|
First, an example of what the working front-end code LOOKS LIKE. It doesn't do anything special that you can see, besides display. Scroll down for the actual ActionScript code.
The entire front-end is done in ActionScript using the Flash MX ActionScript Drawing API. And now for the code:
/*
Flash MX Remoting Client Login
Author: Douglas Palovick
Version: 1.0
License: GPL http://www.gnu.org/licenses/gpl.txt
*/
stop();
/////////////////////////////////////////
// Include necessary librarys for remoting and debugging
#include "NetDebug.as"
#include "NetServices.as"
// ESTABLISH REMOTE CONNECTION #######################
NetServices.setDefaultGatewayURL(
"http://192.168.1.3/test_remoting/simple_gateway.php");
var conn = NetServices.createGatewayConnection();
var service = conn.getService("myas", this);
// HANDLER FUNCTIONS ###############################
//
function passwdcheck_Result(result) {
trace("Got result \""+result+"\" of type "
+typeof (result));
}
function sendpasswd_Result(result) {
trace("Got result \""+result+"\" of type "
+typeof (result));
}
//TEXT FIELDS
pass1 = "passField1_txt";
pass2 = "passField2_txt";
pass3 = "passField3_txt";
pass4 = "passField4_txt";
pass5 = "passField5_txt";
function createField(field_name,text,input) {
this[passBox][field_name].text = text;
if (arguments[2] == 1) {
this[passBox][field_name].type = "input";
}
this[passBox][field_name].selectable = true;
this[passBox][field_name].border = true;
this[passBox][field_name].borderColor = 0x000000;
this[passBox][field_name].textColor = 0x000000;
this[passBox][field_name].multiline = true;
this[passBox][field_name].wordWrap = true;
}
var passBox = "passBox_mc";
this.createEmptyMovieClip("passBox_mc",1);
if (!_global.foo) {
continue;
}
else {
this.passBox_mc._visible = false;
}
this.passBox_mc.lineStyle(2, 0x000000, 100);
this.passBox_mc.moveTo(0,0);
this.passBox_mc.lineTo(0,200);
this.passBox_mc.lineTo(300,200);
this.passBox_mc.lineTo(300,0);
this.passBox_mc.lineTo(0,0);
this[passBox]._x = -150;
this[passBox]._y = -100;
// position as necessary
this.passBox_mc._x = this._x + 20;
this.passBox_mc._y = this._y + 125;
this[passBox].createTextField(pass1,3,10,40,
180,20);
createField(pass1,"Type text here",1);
// PASSBOX 2
passBox_mc.createTextField("passField2_txt",
2,10,80,180,20);
this[passBox][pass2].password = 1;
createField(pass2,"type text here",1);
// PASSBOX 3
this[passBox].createTextField(pass3,4,5,5,
180,20);
createField(pass3,"Client Login",0);
this[passBox][pass3].border = 0;
// PASSBOX 4
passBox_mc.createTextField(pass4,10,10,170,
180,20);
createField(pass4,"Enter your username",1);
// Delete text onfocus
this[passBox][pass4].onSetFocus = function(oldfocus) {
this._parent[passBox][pass4].text = "";
};
// Text for lost password
this[passBox].createTextField(pass5,7,10,110,220,50);
this.createField(pass5,
"If you have lost or forgoten your password\n" +
"enter your username below. Your password\n" +
"will be emailed to you",
0);
this[passBox][pass5].border = false;
// Login button #######################################
//
this[passBox].createEmptyMovieClip("butt1_mc",5);
this[passBox].butt1_mc._x = 160;
this[passBox].butt1_mc._y = 116;
this[passBox].butt1_mc.onRelease = function() {
username = this._parent._parent[passBox][pass1].text;
password = this._parent._parent[passBox][pass2].text;
_root.service.passwdcheck(username,password);
}
this[passBox].butt1_mc.onRollOver = function() {
this.foo.text = " HI";
}
this[passBox].butt1_mc.onRollOut = function() {
this.foo.text = " OK";
}
this[passBox].butt1_mc.createTextField("foo",1,80,-32,
26,18);
this[passBox].butt1_mc.foo.text = " OK"
this[passBox].butt1_mc.foo.border = 1;
// Forgot password button #################################
//
// Forgot-Password-button creation and style
this[passBox].createEmptyMovieClip("butt2_mc",8);
this[passBox].butt2_mc._x = 220;
this[passBox].butt2_mc._y = 210;
this[passBox].butt2_mc.onRollOver = function() {
this.foo.text = " HI"; }
this[passBox].butt2_mc.onRollOut = function() {
this.foo.text = " OK"; }
this[passBox].butt2_mc.createTextField("foo",1,20,-37,
26,18);
this[passBox].butt2_mc.foo.text = " OK"
this[passBox].butt2_mc.foo.border = 1;
// Forgot-password-button functionality
this[passBox].butt2_mc.onRelease = function() {
username = _root[passBox][pass4].text;
_root.service.sendpasswd(username);
}
Next: The AMFPHP PHP back-end code |