A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: Sending Variables to a Database

  1. #1
    Junior Member
    Join Date
    Apr 2008
    Posts
    28

    Sending Variables to a Database

    For anyone that knows how to send data via ActionScript 3.0, I just wanted to make sure that my code is on the up-and-up. I'm having some problems getting my data to send, and I'm wondering if it's on me, or on my client's backend.

    Code:
    function add_score():void {
         var myRequest:URLRequest = new URLRequest(baseVar + "main add_record");
         var myLoader:URLLoader = new URLLoader();
         var myVars:URLVariables = new URLVariables();
         myLoader.addEventListener(Event.COMPLETE, handleLoadSuccessful);
         myLoader.addEventListener(IOErrorEvent.IO_ERROR, handleLoadError);
         myVars.score = int(score);
         myVars.game_id = int(game_idVar);
         myVars.init_score = int(init_score);
         myVars.correct = int(correct);
         myVars.wrong = int(wrong);
         myVars.played_time = playedTime;
         myRequest.data = myVars;
         myLoader.dataFormat = URLLoaderDataFormat.VARIABLES;
         myRequest.method = URLRequestMethod.POST;
         myLoader.load(myRequest);
    }
    I typecast ints to make sure that the data is sent as integers. The example that I was given also did the same.

    This code seems to go along with what has worked in the past, and tutorials that I have found on the Web. I would send my client a message, but I guess I've sent him too many, and it's become an annoyance (he also doesn't deal with the technical aspects). I want to make sure that my code is right before I send any more messages at all. Thank you.
    Send me a PM if you're interested in mini Flash games.
    Examples of my work: Arian Starfighter, Hikouki Consecution
    I'm interested in doing small-scale games at the moment.

  2. #2
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    Your URLRequest does not look correct. It has a space in it. What URL are you trying to send to?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center