getting value from score variable in Flash

孤街醉人 提交于 2019-12-11 12:35:55

问题


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.


回答1:


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



来源:https://stackoverflow.com/questions/7183786/getting-value-from-score-variable-in-flash

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!