View Full Version : problem when reloading page multiple times with loadVariablesNum/PHP

04-15-2009, 10:56 PM
Alright, I will try to be as detailed as possible..I am working on a multiplayer game ( www.battlebubes.com (http://www.battlebubes.com) ).. the way the game works is that there a bunch of sections...every time the player goes to a section...the flash file(AS2-flash 8) sends info to 2 different php files, which in turn connect to the mysql database...then the php file sends the info back to flash...this all works fine...until you try to do things to quickly(the easiest example is if I try to reload a section a bunch of times--the first 5 or 6 times..everything works fine...but then it gets progressively slower)
At first I thought it was a problem with my php or mysql...but then I did a test where I set variables for all the times in the frames and in the php code.
It turned out that the php and mysql were fine, but as you can see below, the times inbetween frames where I send and recieve info from the php files are where all the time is taking(the following are the results after I reloaeded the section about 10 times...they get longer and longer if I keep reloading)
Frame 1 and 4 is where the loadVariablesNum is

frametime1 = 1239834050.984 -
frametime2 = 1239834055.843 -
frametime3 = 1239834055.921 -
frametime4 = 1239834056.015 -
frametime5 = 1239834061.671 -
frametime6 = 1239834061.765 -

what could be some possible reasons?

04-16-2009, 01:24 AM
alrighty, after some more research...I found that it has to do with the sending of variables...once the info gets to the php file, it gets recieved back fast. So now that I know the problem is how flash is sending the info...I am at a loss on why this is happening.
Since I am just reloading the same section over and over...nothing has changed-and it works fine for the first bunch of times. Does the flash read all the data in from the php file and somehow count it as new info and this creates more and more info to send as you go about the game?...I have been searching online all day and can't believe nobody else has run into this issue

04-16-2009, 10:17 PM
The short answer is that it's a memory problem, your overclocking your server.
You can see this in action on your test setup.
I ran into this same thing not too long ago, i don't know what your test setup is, but on my test setup, (apache on xp), the overclock could be seen in the task manager (the computer would run above 90 to 99%) the same thing is most likely happening on your server, thereby slowing things down.
The solution is xml sockets, so that you can have a live connection to the server. Sockets are complex to handle but for a multiplayer game they are a must. It involves having a socket server between your flash and your main server.

This problem is something inherent to flash. It's something they've delt with in AS3.
Another solution is to make sure that calls from the flash to the server don't happen too soon together, to prevent the overclock they need to be at least one second apart, but of course in the case of a multiplayer game, this is not wanted in most cases, so xml sockets are needed.

hope this helps