I have a flash game. I want to send my score to the database by .php. How can i do that? I have written some posts but i couldn’t figure it out how. What should i do in actionscript 3 side and php side? my database name is my_db and my variable is _score.
Share
First you need to create an URLLoader and store the variables you want to send into the header of the request.
After loading the URL and sending the variables we listen for the COMPLETE event so we can get variables from PHP back to Flash.
ActionScript 3 Code:
In PHP we receive the variables with the method POST from Flash and can use them with $_POST[‘xxx’]. We insert the score into a database and we check if the INSERT was a success or not and send this variable back to the “browser”/Flash.
PHP Code (I’m using PDO for database operations: http://php.net/manual/de/book.pdo.php):