# \[AS2\]Actionsscript/Mysql Lag woes\[CS4\]

**URL:** <https://forum.kirupa.com/t/as2-actionsscript-mysql-lag-woes-cs4/296627>\
**Category:** flash\
**Created:** [September 17, 2009, 1:34pm UTC](https://forum.kirupa.com/t/as2-actionsscript-mysql-lag-woes-cs4/296627 "2009-09-17T13:34:20Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Signy](https://avatars.discourse-cdn.com/v4/letter/s/5e9695/32.png) [@Signy](https://forum.kirupa.com/u/Signy)\
**Post date:** [September 17, 2009, 1:34pm UTC](https://forum.kirupa.com/t/as2-actionsscript-mysql-lag-woes-cs4/296627/1 "2009-09-17T13:34:20Z")

</div>

Hi all,

Im currently making a small flash car game (think football manager with cars) and have run into a little lag problem when communicating with my mysql server through php.

This is my current code.

```auto
dynamic class scripts.actionScript.masterScript extends MovieClip{
    
    var sendingVars:LoadVars;
    var recievingVars:LoadVars;
    
    function masterScript(){
        _global.carMake = "";
        _global.carBhp = 0;
        _global.carHandling = 0;
        _global.weight = 0;
        _global.reliability = 0;
        _global.aerodynamics = 0;
    }
    function loadCarStats(userCarId){
        sendingVars = new LoadVars();
        recievingVars = new LoadVars();
        
        recievingVars.onLoad = function(phpLoaded){
            if(phpLoaded){
                _global.carMake = recievingVars.username;
                _global.carBhp = recievingVars.bhp;
                _global.carHandling = recievingVars.handling;
                _global.weight = recievingVars.weight;
                _global.reliability = recievingVars.reliability;
                _global.aerodynamics = recivingVars.aerodynamics;
            }
            trace(_global.carMake);
        }
    sendingVars.sendAndLoad("http://localhost/cargame/scripts/php/cars.php"+userCarId,recievingVars,"POST");
    
    }
    function onEnterFrame(){
        
    }
}

```

Now I know my mysql and flash are communicating the only problem is they are not communicating fast enough when I take this code off the timeline and put it into a stand alone .as file.

For example

```auto
_global.carMake = recievingVars.username;

```

will trace undefined, but if i trace just recievingVars.username on the onEnterFrame function after about two frames it will start tracing the value taken from the database.

The thing is this really doesn’t help me as

```auto
function loadCarStats(userCarId)

```

is being called from a serperate .as file only once in order to set up the car befor you modify it. The reason onEnterFrame is not an option is once the base car stats have been loaded you can change them but if they are constantly being called then no matter how many times you change them it will just revert to the base settings.

Has anyone experianced lag problems like this befor? The only solution I can think of is making a loop that will hold up the code until everything is loaded which I don’t really want to do would much rather get this method working properly.

Thanks in advance if anyone can shed some light on the situation.

Take it easy
