1

I am editing a flash game,I want that whenever user press the submit button,his score should be saved in the database at my Server.How i can achieve this task?I had got the variable in which score is stored.I can i send this to my database.

require_once
  • 1,995
  • 3
  • 21
  • 29

1 Answers1

0

You need some sort of server side scripting language that you can communicate with, the flash code can't directly insert things into a database it can only encode the data for transmission across the network and deliver it to a server side script that can then insert it into the database. This is basically for security reasons generally speaking you don't just want your database open for people to insert things into it from wherever on the internet. You can use PHP or Java or C# or Perl or Python or all sorts of other languages to achieve the task of connecting to a database and inserting the data received from the flash player. For more info on the AS3 side of things look here:

Below taken from this page: http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/net/URLRequest.html#methodSummary

Note: To run the example, the remote application URL in the example must be replaced with a working URL. Additionally, you would need server code to process the information captured by Flash Player in the URLVariables object.

package { import flash.display.Sprite; import flash.net.navigateToURL; import flash.net.URLRequest; import flash.net.URLVariables;

public class URLVariablesExample extends Sprite {

    public function URLVariablesExample() {
        var url:String =

"http://www.[yourDomain].com/application.jsp"; var request:URLRequest = new URLRequest(url); var variables:URLVariables = new URLVariables(); variables.exampleSessionId = new Date().getTime(); variables.exampleUserLabel = "guest"; request.data = variables; navigateToURL(request); } } }

shaunhusain
  • 19,630
  • 4
  • 38
  • 51
  • I had seen that in an action script there is a variable TOTALPOINTS that stores the point.now that what should i do when the user clicks on the Submit button,I am very new in Flash CS. I want to use Php – require_once Aug 25 '11 at 16:23
  • sorry ZainShah I can't answer this at the moment since I'm at work and am a bit backed up, if I have time later in the evening I'll get back to this but for starters you can read up a bit about it here: http://active.tutsplus.com/tutorials/actionscript/create-a-flash-login-system-using-php-and-mysql-part-1/ there's a lot of ways to do this some more complicated than others and it depends on the complexity of the project in terms of which option should be chosen but like I said I'll write one up later that's simple and post it to my server if no one else answers by then – shaunhusain Aug 25 '11 at 18:46
  • Let me know if you looked through the tutorial and you're still hung up on something, I just flipped through it all and it seems it contains all the elemental pieces you'd need to make this work, rather than re-write the article I think it's probably best if I just help you work through it. – shaunhusain Aug 25 '11 at 21:04
  • Thanks shaunhusain for your help...so nice of you – require_once Aug 25 '11 at 23:34