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.

有帮助吗?

解决方案

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); } } }

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top