Forum Moderators: open
If it's too much complicated to edit this script to convert it for as3 could you give me some info about sending data through flash in a mysql database
Thanks!
Here's the errors the compiler gives me when i put it in a AS3 flash file :
function getEntries():Void{
function populateTextbox():Void{
function clearTextFields():Void {
mcPopup.mcOK.onRelease = function():Void{
mcPopup._visible = false;
xmlData.onLoad = populateTextbox;
xmlData.load("process.php?rand=" + new Date().getTime());
var lvReceive:LoadVars = new LoadVars();
var lvSend:LoadVars = new LoadVars();
mcSubmit.onRelease = function() {
mcLoading._visible = true;
mcPopup._visible = true;
_root["mcPopup"]["message"+i+"_txt"].text = errorMessages[i];
xmlData.parseXML(unescape(this));
mcLoading._visible = false;
_root["mcPopup"]["message"+i+"_txt"].text = "";
Here's the AS2 script :
mcLoading.tLoad.autoSize = "left";
var errorMessages:Array = new Array();
var formValidated:Boolean;
mcPopup._visible = false;
var xmlData:XML = new XML();
xmlData.ignoreWhite = true;
var rootNode:XMLNode;
xmlData.onLoad = populateTextbox;
getEntries();
function getEntries():Void{
xmlData.load("process.php?rand=" + new Date().getTime());
}
//-------------------------------- INSERTING FUNCTIONALITY ------------------------------------------------------//
var lvReceive:LoadVars = new LoadVars();
var lvSend:LoadVars = new LoadVars();
mcSubmit.onRelease = function() {
clearTextFields();
errorMessages.length = 0;
formValidated = checkForm();
if(formValidated){
lvSend.name = tName.text;
lvSend.email = tEmail.text;
lvSend.message = tMessage.text;
lvSend.sendAndLoad("process.php", lvReceive, "POST");
mcLoading.tLoad.text = "Envoi des données...";
mcLoading._visible = true;
}else {
mcPopup._visible = true;
//populate textfields with the error messages
for (var i = 0; i<errorMessages.length; i++) {
_root["mcPopup"]["message"+i+"_txt"].text = errorMessages[i];
}
}
};
//popup ok button
mcPopup.mcOK.onRelease = function():Void{
this._parent._visible = false;
}
lvReceive.onLoad = function(bSuccess:Boolean) {
if (bSuccess) {
if (this.entryadded != "FAIL") {
xmlData.parseXML(unescape(this));
populateTextbox();
}
} else {
trace("Aucune réponse du serveur...");
}
};
//-----------------------------------------------------------------------------------------------------------//
function populateTextbox():Void{
rootNode = xmlData.firstChild;
tEntries.text = "";
tEntries.html = true;
for(var i:Number=0; i < rootNode.childNodes.length; i++){
tEntries.text += "<b>Nom:</b> " + rootNode.childNodes[i].childNodes[0].firstChild + "\n";
tEntries.text += "<b>Email:</b> " + rootNode.childNodes[i].childNodes[1].firstChild + "\n";
tEntries.text += "<b>Date:</b> " + rootNode.childNodes[i].childNodes[2].firstChild + "\n";
tEntries.text += "<b>Message:</b> " + rootNode.childNodes[i].childNodes[3].firstChild + "\n";
tEntries.text += "-------------------------------------------------------\n";
}
mcLoading._visible = false;
tName.text = "";
tEmail.text = "";
tMessage.text = "";
}
//-------------------------------- VALIDATE FORM -------------------------------------------------------//
function checkForm():Boolean {
//check whether the name field is empty
if (tName.text == "") {
errorMessages.push("S.V.P entrez votre nom.");
}
if (tEmail.text == "") {
errorMessages.push("S.V.P entrez votre email.");
} else if (tEmail.text.indexOf("@") == -1 || tEmail.text.indexOf(".") == -1) {
errorMessages.push("S.V.P entrez un email valide.");
}
if (tMessage.text == "") {
errorMessages.push("S.V.P entrez votre message.");
}
//if at this point the array is empty i.e has length 0, then this in effect means the form has passed all checks
if (errorMessages.length == 0) {
return true;
} else {
return false;
}
}
function clearTextFields():Void {
for (var i = 0; i<errorMessages.length; i++) {
_root["mcPopup"]["message"+i+"_txt"].text = "";
}
}