A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: Send variable to php page in AS3

  1. #1
    anyone else hear that? flashpipe1's Avatar
    Join Date
    Jan 2003
    Location
    Upstate NY
    Posts
    1,929

    Send variable to php page in AS3

    I've got a flash course that needs to pass the current screen number from the course to the mySQL database. The person who built the back-end built a php page that I can pass the number to and it will get written to the db but I'm not sure how to "send" that in the background.

    He told me that I just need to call the index.php page like:
    www.url.com/index.php/user/bookmark/13 (where 13 is the screen number)

    So, would I use URLRequest for something like that??

    Something like this maybe?:

    Code:
    var vars:URLVariables = new URLVariables();
    vars.theData = data;
    var req:URLRequest = new URLRequest("www.url.com/index.php/user/bookmark/"+slideNum);
    req.method = URLRequestMethod.POST;
    req.data = vars;
    
    var loader:URLLoader = new URLLoader();
    loader.dataFormat = URLLoaderDataFormat.VARIABLES;
    loader.addEventListener(Event.COMPLETE, onDataIn);
    loader.load(req);
    I don't need to get anything back from the db, but I'm not sure what the basic call to pass in the background is in AS3...

    Would appreciate any help...
    Love like you've never been hurt, live like there's no tomorrow and dance like nobody's watching.

  2. #2
    Senior Member jweeks123's Avatar
    Join Date
    Mar 2006
    Posts
    1,124
    Well it appears your doing it right although I do see one thing right way that may cause your problems:

    you need to add an http:// call to your url, and what is the user/bookmark and the +slideNum after the PHP file? Are those more arguments? or should the link be just the php file? That too could cause another issue.
    Code:
    var vars:URLVariables = new URLVariables();
    vars.theData = data;
    var req:URLRequest = new URLRequest("http://www.url.com/index.php");
    req.method = URLRequestMethod.POST;
    req.data = vars;
    
    var loader:URLLoader = new URLLoader();
    loader.dataFormat = URLLoaderDataFormat.VARIABLES;
    loader.addEventListener(Event.COMPLETE, onDataIn);
    loader.load(req);

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