PDA

View Full Version : loadVariables to LoadVars


Jiffy Loop
07-09-2002, 12:04 AM
I have some source code that was originally created in Flash 5. I'm trying to rewrite the code in Flash MX using the new LoadVars Object. I'm just having a little difficulty trying to rewrite the syntax. The project I'm working on is an email form with a few fields and a submit button. After entering the form, the submit buttons sends this to a PHP file which then sends out the email. This is what I have so far:

//Frame 1:
fscommand ("allowscale", "false");
mailform = "mailform.php";
action = "";
stop ();

//Frame2:
loadVariablesNum(mailform, 0);
answer = "please wait for confirmation ...";
stop();

//Button:
on (release) {
if ((vemail.indexOf("@") != -1) && (vemail.indexOf(".") != -1) && (length(vemail)>5)) {
action = "Send";
loadVariablesNum("mailform.php", 0, "POST");
nextFrame();
} else {
vemail = "Please enter email";
action = "";
stop();
}
}

So basically my question is, how do I rewrite the loadVariables to use the new LoadVars?? I get confused with the new methods of send, sendAndLoad and load....

Any help would be appreciated.

jiffy loop

Jesse
07-09-2002, 02:57 AM
Not specific to your example but...
myVars = new LoadVars();
myVars.load(mailform);
myVars.onLoad = function(success) {
// Your code here. Note your variables are now stored
// in the myVars object so to access them from _root you
// use myVars.varName . In this function you can just use
// varName though or this.varName as it runs as a method of the object.
};

Mortimer Jazz
07-28-2002, 04:14 PM
so if I do this:

//send my returned variables to _root
sendData = new LoadVars();
sendData.firstVar = "hey";
sendData.sendAndLoad("returnvals.php", _root, "POST");

do I need the 'sendData.onLoad' code (and therefore, to access all my variables from outside the function as: sendData.varName)

or can I just access my returned variables as _root.varName ?

Mortimer Jazz
07-28-2002, 04:40 PM
stop();
btnSend.setClickHandler("send");

function send(){
sendData = new LoadVars(); //create new object
sendData.firstVar = "hey"; //set property
sendData.sendAndLoad("returnvals.php", _root, "POST");
}

sendData.onLoad = function(success) {
if(success){//don't think I need this if
debug += "hi!";
}else{
debug += "ho!";
}
};

it works with loadVariables.
Does the onLoad function when data is successfully sent or recieved?

my php is:

<?
$recievedVal = $firstVar;
echo "&debug=yes!!!" . urlencode($recievedVal);
?>


thanks

Jesse
07-29-2002, 09:48 AM
The vars that are returnned will be returned to another loadVars object so you'll have to use a relative path as far as I'm aware. Because the sending happens from sendData but the vars should be recieved by another LoadVars obj from my reading of the documentation... does targetting _root as the return point work?