Page 1 of 1

[Help!] Reduce Lag

Posted: 01 Mar 2009, 13:49
by x.Mara.x
I need to reduce the lag for my project, it is not the server, it is the .fla file; each time that the user moves 1 tile 20 variables are sent and updated, making you see the others walk really really slow.. how can i reduce the lag?

Posted: 01 Mar 2009, 17:34
by Lapo
You can by reducing the number of variables that you update (20 seems quite a lot, on every move) and the amount of updates per seconds.
Take into consideration that a good client conection can't handle more than 15-20 updates per second (50-70ms) and a not-so good one can handle <= 10 msg/second.

Posted: 03 Mar 2009, 19:50
by x.Mara.x
its that all variables seem to be essencial.. i mean i do not know how to reduce them.. because these are the variables that are essencial:

py
px
movefeat
look
init

but they are updating to often, if i dont update them though.. it doesnt work well.. the user sees other users moving really slooww

is there a way like.. umm.. putting all the values in 1 variable and then exploding them?
example:
instead of:
py
px
movefeet
look
init
(5), only one.. like this
all = py+","+px+","+movefeet+","+"look";
would that work?

Posted: 04 Mar 2009, 09:21
by aMUSiC
Of course you can. You can either join your values into a single string using a delimiter (like a coma, but I prefer a pipe |, i.e. 14|56|4|19|1 ), or if you use standard lengths for your values, you can even put them as a a series of non delimited values (adding leading zeros to make them uniform i.e. 014056040191) and use substr or modulus to take the portion you need.

Use Array.join() and Array.split() for imploding/exploding (you're a php person eh?).

This will severely reduce the amount of traffic, HOWEVER you will add more calculations to the client which has to do the extra step of joining and splitting the values (which under normal circumstances is negligable).

Posted: 05 Mar 2009, 19:49
by x.Mara.x
how do you know im a php person o.o wow.. haha.. well ill try although i dont know how to do the exploding in the AS.. will it be something like this?:

when sending

var allin:Number = movefeet+","+ etc...

smartfox.setUserVariables(allin);

when receiving
myarray = Array.split(userObj, ",");
user._movefeet = myarray[0]

.. idk..