A Flash Developer Resource Site

Results 1 to 7 of 7

Thread: Sending POST Data

  1. #1
    Senior Member SpikeyOmega's Avatar
    Join Date
    Dec 2004
    Posts
    400

    Question 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!

  2. #2
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    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.

  3. #3
    Senior Member SpikeyOmega's Avatar
    Join Date
    Dec 2004
    Posts
    400
    That only works if you're loading a page in another window, not if you're loading the data back into Flash.

  4. #4
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    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.

  5. #5
    Senior Member SpikeyOmega's Avatar
    Join Date
    Dec 2004
    Posts
    400
    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???

  6. #6
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    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);

  7. #7
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,449
    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
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center