Action Script 3. How to get data from swf (as) to php and write to database

I'm creating Flash "memory" game, Idea to discover 2 equal cards. Here is timer which count time in how many seconds all cards are discovered. After complete game timer stops. How can I get this time from swf file and write to database? As I understand I need take this data with php file, but don't have idea how to do It.

As I know I need to do something like that:

        var urlLoader:URLLoader = new URLLoader();
        urlLoader.addEventListener(Event.COMPLETE, scoreSaveResponse,false,0,true);
        var request:URLRequest = new URLRequest("http://mysite.com/score.php");
        var urlVars:URLVariables = new URLVariables();
            urlVars.time = timer.currentCount;
            urlVars.userName = "yourUserName";

        request.method = URLRequestMethod.POST;
        urlLoader.data = urlVars;
        urlLoader.load(request);

function scoreSaveResponse(e:Event):void {
    //whatever you return from the php page is found in urlLoader.data
}

//LondonDrugs_MediaServices's code 

But could someone explain me how to do It, because If I use this part of code nothing happens, I don't get any errors, but I don't know how to use this in php or how to write it to database.

My app will be used for Facebook, that's mean username will be used the same as in Facebook. So I think first i need to get time to PHP than get username from Facebook and write both to database.

Thank you for answers.

Answers


Try to use AMFPHP. AMFPHP makes it possible to write a service for your application where you can store your SWF values into a PHP database.

http://www.silexlabs.org/amfphp/


Need Your Help

CSS only thumbnail slider

css slider thumbnails

I'm trying to make a thumbnail which on hover will move it's image (that's longer that the wrapper) all the way to the left using only css and using the img element and not a div with background-im...

Change jQuery image src dynamically

jquery dynamic slideshow jquery-backstretch

I saw just wondering how it would be possible to change a src every say 5 seconds,