Search code examples
sqlactionscript-3flashswfobject2d-games

How can i add some score stored in a variable to a SQL database from a SWF? - AS3


I have a game in SWF with AS3 that scores points and stores it on a variable called "Puntos". Here's how I'm doing it:

stop();
var puntos:int = new int();


add_puntos.addEventListener(MouseEvent.CLICK, agregar);

function agregar(event:MouseEvent):void
{
    puntos=puntos+3;
    puntos_txt.text=String(puntos);
    trace(puntos);
}

Now, i have to take the result of the variable "puntos" and add it to the absolute score of the player on a SQL Database. ¿How can i do it? :(

UPDATE: Thanks Andrey. Effectively, it's not for mobile. I'm going to try it :)


Solution

  • You need backend knowledge in order to save those scores (or if you are working on a mobile - at least SQL knowledge).

    The client part is easy - sending a simple POST request to the server, where all the magic happens. You can see the examples here: http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/net/URLLoader.html#includeExamplesSummary

    If you are working on a mobile - things get harder, and you would need go search Google instead :)

    Edit: Having in mind you are using mobile device, this is for you: http://help.adobe.com/en_US/as3/dev/WS5b3ccc516d4fbf351e63e3d118676a5497-7fb4.html