Código ActionScript :
import fl.motion.MotionEvent;
import flash.net.URLVariables;
import flash.net.URLRequest;
import flash.net.URLLoader;
this.datosUser = new URLLoader();
this.respuesta = new URLLoader();
respuesta.onLoad= function() {
if (this.error == 0) {
} else {
}
};
this.isMail = function (arg){
if (arg =="" || arg == null || arg == "null" || arg == undefined || arg == "undefined") {
return false;
} else if (arg.indexOf("@") == -1 || arg.indexOf("@") != arg.lastIndexOf("@")) {
return false;
} else {
var partes = arg.split("@");
var usuario = partes[0];
var dominio = partes[1];
if (usuario.length<1) {
return false;
} else {
var caracteresProhibidos = new Array ("°", "ª", "!", "#", "$", "%", "&", "¬", "/", "(", ")", "=", "?", "¿", "¡", ",", ";", ":", "[", "]", "{", "}", "á", "à", "ñ", "~", "é", "è", "í", "ì", "ó", "ò", "ú", "ù", "Á", "À", "É", "È", "Í", "Ì", "Ó", "Ò", "Ù", "Ù", "Ç", "ç");
var numCaracteresProhibidos = 0;
for (var k = 0; caracteresProhibidos[k]; k++) {
if (usuario.indexOf(caracteresProhibidos[k]) != -1) {
numCaracteresProhibidos++;
}
}
if (numCaracteresProhibidos>0) {
return false;
} else if (dominio.indexOf(".") == -1 || dominio.length<1) {
return false;
} else {
var partes_dominio = dominio.split(".");
var extension = partes_dominio[partes_dominio.length-1];
if (dominio.length-extension.length<4) {
return false;
} else if (extension.length<2 || extension.length>4) {
return false;
} else {
return true;
}
}
}
}
};
this.isBlank = function (valor) {
if (valor == "" || valor == undefined || valor == null || valor.length<1) {
return true;
} else{
return false;
}
{
if (isBlank(nombre_txt)) {
_parent.submitForm_mc.avisar ("Por Favor Introducir Nombre");
}else {
if (isBlank(mail_txt)) {
_parent.submitForm_mc.avisar ("Introducir Correo Electronico");
} else {
if (!isMail(mail_txt)) {
_parent.submitForm_mc.avisar ("Correo Electronico Invalido");
} else {
if (isBlank(mensaje_txt)) {
_parent.submitForm_mc.avisar ("Por Favor Introducir Mensaje");
} else {
function enviarCorreo(e:MotionEvent):void {
var variables:URLVariables = new URLVariables();
variables.nombre=nombre_txt.text;
variables.email=mail_txt.text;
variables.mensaje=mensaje_txt.text;
var phpReq:URLRequest = new URLRequest("mail.php");
phpReq.data = variables;
phpReq.method = URLRequestMethod.POST;
var loader:URLLoader = new URLLoader();
loader.dataFormat= URLLoaderDataFormat.VARIABLES;
loader.load(phpReq);
};
}
}
}
}
}
} 