Ok, here's the dilemma that i hope someone might be able to help me with. I am creating a contact form that will collect user data that is to be passed to a .php script that will then create and store the info in an .xml formatted file for accessing later.
I was trying to use the loadVariables function to pass the information to my .php script, but I kept receiving an error message in the output window saying that there was an error accessing the URL of my .php script (absolute URL used, not relative). So I decided to try the LoadVars method to send my data to my .php script, however I'm a bit confused about something.
I have created 5 input boxes in my .fla for storing my data and I have given them the variable names (variable name, not instance name) of:
firstName
lastName
phoneNumber
emailAddr
schoolName
I then enclosed all of my input boxes into a movieclip which I gave the instance name of form. Since I have given my input boxes variable names, I am confused as to how I should refer to them in the LoadVars ActionScript. Should I refer to each of them by the variable name that I have assigned to each box?
var myVars = new LoadVars();
form.myVars.firstName = firstName;
form.myVars.lastName = lastName;
form.myVars.phoneNumber = phoneNumber;
form.myVars.emailAddr = emailAddr;
form.myVars.schoolName = schoolName;
Or is there another way that I'm supposed to reference my variables inside the form movieclip when using LoadVars?
var myVars = new LoadVars();
form.myVars.firstName
form.myVars.lastName
form.myVars.phoneNumber
form.myVars.emailAddr Flashvalley - Flash tutorials - LoadVars:: Oct 8, 2007 Learning to use the LoadVars class to load variables in Flash. (ActionScript 2.0 Language Reference) If you use onData and onLoad in the http://www.flashvalley.com/fv_tutorials/LoadVars/page2.php?show_comments=trueHOME | detect if local file:: loadVariablesNum("something.php",0,"GET");. is a pretty specific reference to a PHP file in the same directory as the Flash movie. http://www.webmasterworld.com/forum88/12753.htmHOME |
form.myVars.schoolName
Thanks guys. The reason that I asked was because I already a nextFrame function call on my submit button to make the .swf jump to a frame showing a loading message (or a progress bar if I could ever get the dern thing to work right...) so that the user isn't just sitting there while the .swf i waiting for the success message to be sent back from my .php script. Basically, it's like this:
Frame 1: User enters in data and presses submit button.
>sendAndLoad function shoots data to .php script.
>nextFrame function jumps the movie one frame. Dynamically Referencing Variables:: Dynamically Referencing Variables. (1/1). willgwitt: I had been using LoadVariables. Based on advice in your your tutorial, I'm trying LoadVars. http://www.flash-db.com/Board/index.php?topic=14720.0;wap2HOME | sending variables, the new way. - kadazuro.blog:: do you remember the time when if you need mimic a form behavior or send variables through the http, you just needed to grab a loadVars ojbect, http://www.kadazuro.com/blog/archives/000128.phpHOME |
Frame 2: Loading message appears.
>.php script processess data, creates and stores data in .xml file.
>.php script sends success message to .swf.
>On receipt of the success message myVars.onLoad/nextFrame function jumps the movie one frame.
Frame 3: User sees a thank you message for entering data and is allowed to proceed to next phase of the process.
This is how I would like the .swf to work. Would that be possible?
Thanks Defective. I'll give it a shot. I appreciate the help.
:thumb2:
Defective: Let me ask you this. Would it be possible to put
myVars.onLoad = function(){
_root.nextFrame();
}
inside a frame instead of inside the ActionScript for my submit button?
PWNd by Alberta again:upset:
Hey all I did was write onPress instead of on(press) :shifty:
np.... i think you'll be fine, if in doubt... don't hesitate the pm me.
Ok, I'm following you. Then when I call the sendAndLoad(); all I have to do is:
on(release) {
form.sendAndLoad("path/to/php/file.com", myVars, "POST");
onClipEvent(data){
_root.nextFrame();
};
}
Is that close?
The loadvars is not contained within that parent, you dont need the "form" thing:
var myVars:LoadVars = new LoadVars();
myVars.firstName = form.firstName;
myVars.lastName = form.lastName;
myVars.phoneNumber = form.phoneNumber;
myVars.emailAddr = form.emailAddr;
myVars.schoolName = form.schoolName;
I could really use some help on this issue. Very much appreciate it!!!
Something like this should work on a frame:
var myVars:LoadVars = new LoadVars();
myVars.onLoad = function():Void {
nextFrame();
};
myButton.onPress = function():Void {
myVars.sendAndLoad("path/to/php/file.php", myVars, "POST");
};
:pope:
Yes, but a little more like this:
on(release) {
myVars.sendAndLoad("path/to/php/file.php", myVars, "POST");
myVars.onLoad = function(){
_root.nextFrame();
};
}
:D
Theres probably a way to do it from where it is, try to keep all AS in an empty layer.
Red Hat's Rough Recovery From CFO Exit
Windows Live Finds a New, Pre-installed Home
|