-
Senior Member
Sending POST Data
I've been picking up AS3 but one of the things that I just can't seem to figure out is how to SEND and LOAD data from a .php file. So far I've been able to load data but I can't give it any parameters. I have written an example of AS2 code, can someone please convert it to AS3 so I can finally see exactly how to do this?
Example:
Code:
var server:LoadVars = new LoadVars();
server.passcode = "ABCDEFG";
server.user = "Person";
server.onLoad = function(){
if (this.loaded == true){
trace(this.returnedData1 + " " + this.returnedData2);
}
}
server.sendAndLoad("http://www.mysite.com/coolpage.php", server, "POST");
Thank you!
-
I'm not going to rewrite your code for you, but I will tell you where to find the stuff you need.
http://livedocs.adobe.com/flash/9.0/...Variables.html
It even comes with helpful example code.
-
Senior Member
That only works if you're loading a page in another window, not if you're loading the data back into Flash.
-
The navigateToURL from the example, yes. However, you should be able to combine URLVariables, URLRequest, and URLLoader to send variables, and load stuff back into flash.
-
Senior Member
Okay I've been trying like crazy to get this to work using the stuff on that page but I still can't figure it out. Can anyone help please???
-
Never tried this, but in theory it should work. Or at least something very similar.
Code:
var urlvs:URLVariables = new URLVariables();
urlvs.somevarname = "someval";
var urlr:URLRequest = new URLRequest("yourdomain.com/upload.php");
urlr.data = urlvs;
urlr.method = "POST";
var loader:URLLoader = new URLLoader();
loader.load(urlr);
-
Senior Member
Download those files. The LoadData file is doing what you want. There is an example, too.
http://flashscript.biz/flashas3/biz/index.html
- The right of the People to create Flash movies shall not be infringed. -
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|