Copy link to clipboard
Copied
Hi,
How would I go about transfering variables from one from to another?
What I want to do is send data from the first frame to a database then retrieve info back and populate form field on the second frame.
At the moment I have the code within the second frame doing everything! What want is to send the username and password enter in the first frame textboxes to a database then displaying the returned info on the second frame.
I already have working php code so this isn't a problem.
Thanks,
Nightwalker
Download and review my attached Fla file. The variable is defined on the first frame. It can be accessed from every other frame in the movie that the "Actionscript" layer extends to.
Enjoy.
Copy link to clipboard
Copied
When I want to have code shared along the timeline I dedicate a layer that extends the length of the timeline without interuption--with everything I want to share defined/assigned in the first frame of the layer. That way, whatever variables and functions in that layer are available anywhere along the timeline
Copy link to clipboard
Copied
Ah ok! I didn't realize I could have two action layers at a time running! I will try that.
Edit:
This is the code I am using for the second frame to display the data from the database:
this["btnSubmit"].addEventListener(MouseEvent.CLICK, submitVars);
//Create the loader object
var Dataloader:URLLoader = new URLLoader();
//Createthe URLRequest object to specify the file to be loaded and the method ie post
var dataurl:String = "http://localhost/flash/dynamicWebsite/getData.php";
var prodreq:URLRequest = new URLRequest (dataurl);
prodreq.method = URLRequestMethod.POST;
prodreq.data = variables;
function submitVars(event:Event):void {
variables.username = tiUser.text;
Dataloader.load(prodreq);
}
function loaddata(event:Event) {
var v:URLVariables = new URLVariables(event.target.data);
tiCustomerID.text = v.cid;
tiFName.text = v.fname;
tiLName.text = v.lname;
tiSNum.text = v.snum;
tiSName.text = v.sname;
tiSuburb.text = v.suburb;
tiPCode.text = v.pcode;
tiCountry.text = v.country;
tiPhone.text = v.phone;
tiEmail.text = v.email;
tiPass.text = v.upassword;
}
Dataloader.addEventListener(Event.COMPLETE, loaddata);
Dataloader.addEventListener(Event.COMPLETE, contentSaved);
function contentSaved(event:Event):void {
var v:URLVariables = new URLVariables(event.target.data);
status_txt.text = "customer: " + v.cid + " loaded";
}
This code works when its same frame as the objects but if move it to the first frame where the login code is it doesn't work. I've tried putting the framename where the objects are located before code in the loaddata function both written like:
customerDetails.tiCustomerID.text = v.cid;
And
["customerDetails"]tiCustomerID.text = v.cid;
However, the variables are still not being put in the boxes on the second form.
Copy link to clipboard
Copied
As the previous poster said, you can have a separate layer for Actionscript that extends to the length of your whole movie. Anything that is defined on this layer will be accessible globally throughout the whole movie.
Works like a charm for what you are trying to do.
Copy link to clipboard
Copied
As I posted above! I have tried it but for some reason the varibles still don't transferred to the text boxes on the second frame.
Copy link to clipboard
Copied
Accidentally double posted. See the following post.
Copy link to clipboard
Copied
Copy link to clipboard
Copied
I have now been able to get it working.
Edit:
I should have said that I was using a pc because your files won't open for me in either CS3 nor CS4.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now