The Scene & components:
Let us see a general image of the form, with all the enumerated components.
Number |
Kind of component |
Name |
Variable |
|---|---|---|---|
1 |
Input text |
FirstName |
|
2 |
Input text |
Email |
|
3 |
Input text |
Company |
|
4 |
Input text |
Comments |
|
5 |
Input text |
About |
|
6 |
Button clip |
||
7 |
Dynamic text |
textos |
EmailStatus |
Layers and its programming:
We are going to enumerate the keyframes that contain programming.
On the keyframe one of the layer Buttons "1"...
stop();
// This code cleans the fields when we returned of the shipment if the user wants to repeat the shipment.
FirstName = "";
Email = "";
Company = "";
Comments = "";
About = "";
EmailStatus = "";
On the button send marked as "6" (image of the paragraph "The Scene & components") in the keyframe one, layer buttons "1";
on(release) {
var partes = Email.split("@");
var usuario = partes[0];
var dominio = partes[1];
var caracteresProhibidos = new Array("º", "ª", "!", "#", "$", "%", "&", "¬", "/", "(", ")", "=", "?", "¿", "¡", ",", ";", ":", "[", "]", "{", "}", "á", "é", "í", "ó", "ú", "Á", "É", "Í", "Ó", "Ú");
var numCaracteresProhibidos = 0;
var partes_dominio = dominio.split(".");
var extension = partes_dominio[partes_dominio.length-1];
for (var k = 0; k<caracteresProhibidos.length; k++) {
if (usuario.indexOf(caracteresProhibidos[k]) != -1) {
numCaracteresProhibidos++;
}
}
if (!FirstName.length) {
EmailStatus = "Introduce your name before the shipment";
} else if (!Email.length || Email == "" || Email == null || Email == "null" || Email == undefined || Email == "undefined") {
EmailStatus = "Please, introduces a mail address";
} else if (!Email.length || Email.indexOf("@") == -1 || Email.indexOf("@") != Email.lastIndexOf("@") || Email.indexOf(".") == -1) {
EmailStatus = "Please, introduces a valid mail address";
} else if (usuario.length<3) {
EmailStatus = "The user mail chain is too short";
} else if (dominio.indexOf(".") == -1 || dominio.length<1) {
EmailStatus = "The mail domain name does not seem valid";
} else if (numCaracteresProhibidos>0) {
EmailStatus = "They do not admit this type of characters in the mail address";
} else if (dominio.length-extension.length<4) {
EmailStatus = "A name of so short domain for a mail address does not exist";
} else if (extension.length<2 || extension.length>4) {
EmailStatus = "The mail domain name is not correct";
} else if (!Comments.length) {
EmailStatus = "Your commentaries are important for us";
} else {
EmailStatus = "";
play();
//If everything is correct, we drained the text field of State of the form and we continued the animation to the next keyframe, where we will make the communication with AMFPHP and we will send the data, awaiting the result.
}
};
On the keyframe two of the layer Buttons "2"...
stop();
// Import the remoting class and debuger to send the message and to analyze the responses of the communication.
import mx.remoting.*;
import mx.rpc.*;
import mx.remoting.debug.NetDebug;
// We declared the address in which we have installed AMFPHP.
// We have two options Here..
// One, that the form is within a presentation CD, outside our server, with which the URL would have to be "http://www.yourserver.com/amfphp/gateway.php".
// Two, that the form this in our server, with which we could use a relative or semiabsolute URL to indicate where to find our door to him AMFPHP.
var gatewayUrl:String = "/amfphp/gateway.php";
// We initiated the debuger to be able to control the results.
NetDebug.initialize();
// We declared the service to which it must call.
var service:Service = new Service(gatewayUrl, null, 'maileador');
// And the corresponding instruction of which it must be pending.
var pc:PendingCall = service.mailear(FirstName, Company, Email, Comments, About);
// The answer relay, as much if it obtains it, as if it gives error.
pc.responder = new RelayResponder(this, "handleResult", "handleError");
// If the result is valid, it will put the message that commands to us in the text field of State of the form, concretely the word "Sending" and will start up the animation.
function handleResult(re:ResultEvent) {
textos.text = re.result;
tempor.play();
}
// If the result fails, shows it in the text field of State of the form and sends us to keyframe 1.
function handleError(fe:FaultEvent) {
textos.text = 'There was an error';
gotoAndStop(1);
}

5 most recent
Flash streaming servers
Tree menu
Flash Spell Checker
Flash Remoting Library
MX 2004 Chart/Poll
Articles