Welcome to WebmasterWorld Guest from 107.20.75.63

Forum Moderators: open

Message Too Old, No Replies

Help here with converting some as2 to as3!

     
5:53 am on Jan 31, 2010 (gmt 0)

Junior Member

5+ Year Member

joined:Nov 16, 2008
posts:136
votes: 0


Hi guys! I've found a script on internet about flash/php/mysql and i really love it but the problem is that my flash file is as3 and the script ive found is as2. So i cant put the script in my flash file... so i need your help for converting the as2 script to as3..

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 = "";

}
}

6:24 pm on Jan 31, 2010 (gmt 0)

Senior Member

WebmasterWorld Senior Member rocknbil is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Nov 28, 2004
posts:7999
votes: 0


Is there a reason you can't just adjust the publish settings of the project to AS2?
12:05 am on Feb 1, 2010 (gmt 0)

Junior Member

5+ Year Member

joined:Nov 16, 2008
posts:136
votes: 0


non there's too much sutff that i use that is only available with as3...