Skip to main content
Inspiring
April 10, 2013
Answered

Pass flash variables to server - the best way?

  • April 10, 2013
  • 2 replies
  • 2171 views

I am using URLVariables at the moment to pass flash variables to the server via php script and update a database rows.

var variables:URLVariables = new URLVariables();

At the moment around 9 variables are sent which are then updated in the mysql db.

I have read that calls to the database via php are the main source of traffic or at least one of them. I am talking about 100 - 500 concurrent users.

Obvously I am going to need expert help medium term but I would like to give things a go myself.

I have read about amfPHP but I don't seem to understand it too well.

Also, I can cut down the amount of php calls per user as I have them all over the place for lots of games and mini exercises.

BUT is it possible to get those nine variables into an object and pass the object. Would one object be faster than passing 9 variables and would that object be placed into one cell of the mysql databse.

What would that look like? At the moment I can read my db easily but if there is an object in there, how do you read that?

Is that what serializning is? Passing an object and all the data is converted to binary etc...

As you see I'm a little lost.

Thanks in advance.

This topic has been closed for replies.
Correct answer

If you are using a URLVariables object, then you're only passing that one object anyway. I would leave that as you have it. You can use Charles, or Fiddler (I prefer Charles) to see all your data being passed - it makes doing this kind of stuff much nicer.

Serializing is simply the process of taking any Flash object, like an Array, and turning it into a format (like clear text) that the server-side script can read.

2 replies

Inspiring
April 12, 2013

Just my two cents.

URLVariables is one of the ways to construct url query. There is no difference in doing it either way (second way is faster):

var request:URLRequest = new URLRequest("http://www.google.com/page.html");

var variables:URLVariables = new URLVariables();

variables.var0 = 3;

variables.var1 = "blah";

request.data = variables;

sendToURL(request);

OR JUST

sendToURL(new URLRequest("http://www.google.com/page.html?var0=3&var1=blah"));

I guess object serialization will be less efficient because, I suspect, it will be a larger string and it is much more processor intensive of both Flash and server side.

I also suspect that http servers have a very efficient way to parse and process requests and variables that come with it - after all this is server's first and the most important duty.

My point is that I don't believe there is anything better than sending data with query string unless there is a need for obfuscation.

As a proof - the fact that large volume and frequent updates sites like advertising servers never use anything but plain old query strings attests to the above points.

As far as DB updates speed goes - it has nothing to do with the means info is sent but rather is a consequence of server and DB performance aspects. It's just a matter of money :-)

Correct answer
April 11, 2013

If you are using a URLVariables object, then you're only passing that one object anyway. I would leave that as you have it. You can use Charles, or Fiddler (I prefer Charles) to see all your data being passed - it makes doing this kind of stuff much nicer.

Serializing is simply the process of taking any Flash object, like an Array, and turning it into a format (like clear text) that the server-side script can read.

Inspiring
April 11, 2013

Thanks for putting me straight on the amfPHP side of things.

Can I just ask you if it is OK to keep using URLVariables in this way to send a students details of where they are on an exercise, the score they got etc... and Update the db with 500 concurrent users.

I know the server is important re: hardware etc... but is the above method suitable for this type of learning management system or would there be a better way to send this data to the server?

Cheers

April 11, 2013

Well, you'll need to test, but 500 users is not that many. Plenty of websites out there, especially gaming ones, have many more users hitting the database. I think any modern database employs locking so really you shouldn't need to worry at all about concurrent users.