[CS4]Arrays,Strings and Objects[AS 2.0]

Hi All,

Right I’ll post my code first then chat about where I’m stuck.

dynamic class scripts.actionScript.enginCode extends MovieClip {
    
    var carOne:Object;
    var carTwo:Object;
    var carThree:Object;
    var carFour:Object;
    var carOnePhp:LoadVars;
    var carTwoPhp:LoadVars;
    var carThreePhp:LoadVars;
    var carFourPhp:LoadVars;
    var carGarage:Array = ["carOne","carTwo","carThree","carFour"];
    
    function enginCode(){
        _global.arrayPlace = 0;
        carUpdate()
    }
    function onEnterFrame(){
        carCreator()
        statusHudUpdate()
    }
    function carUpdate(){
        carOnePhp = new LoadVars();
        carOnePhp.load("http://localhost/cargame/scripts/php/cars.php?id=1");
        
        carTwoPhp = new LoadVars();
        carTwoPhp.load("http://localhost/cargame/scripts/php/cars.php?id=2");
        
        carThreePhp = new LoadVars();
        carThreePhp.load("http://localhost/cargame/scripts/php/cars.php?id=3");
        
        carFourPhp = new LoadVars();
        carFourPhp.load("http://localhost/cargame/scripts/php/cars.php?id=4");
    }
    function carCreator(){
        carOne                     = new Object();
        carOne.make             = carOnePhp.make;
        carOne.cost             = Number(carOnePhp.cost);
        carOne.bhp                = Number(carOnePhp.bhp);
        carOne.handling            = Number(carOnePhp.handling);
        carOne.weight            = Number(carOnePhp.weight);
        carOne.reliability        = Number(carOnePhp.reliability);
        carOne.aerodynamics        = Number(carOnePhp.aerodynamics);
        carOne.total            = (carOne.bhp+carOne.handling+carOne.reliability+carOne.aerodynamics) - carOne.weight;
        
        carTwo                     = new Object();
        carTwo.make             = carTwoPhp.make;
        carTwo.cost             = Number(carTwoPhp.cost);
        carTwo.bhp                = Number(carTwoPhp.bhp);
        carTwo.handling            = Number(carTwoPhp.handling);
        carTwo.weight            = Number(carTwoPhp.weight);
        carTwo.reliability        = Number(carTwoPhp.reliability);
        carTwo.aerodynamics        = Number(carTwoPhp.aerodynamics);
        carTwo.total            = (carTwo.bhp+carTwo.handling+carTwo.reliability+carTwo.aerodynamics) - carTwo.weight;
        
        carThree                 = new Object();
        carThree.make             = carThreePhp.make;
        carThree.cost             = Number(carThreePhp.cost);
        carThree.bhp            = Number(carThreePhp.bhp);
        carThree.handling        = Number(carThreePhp.handling);
        carThree.weight            = Number(carThreePhp.weight);
        carThree.reliability    = Number(carThreePhp.reliability);
        carThree.aerodynamics    = Number(carThreePhp.aerodynamics);
        carThree.total            = (carThree.bhp+carThree.handling+carThree.reliability+carThree.aerodynamics) - carThree.weight;
        
        carFour                 = new Object();
        carFour.make             = carFourPhp.make;
        carFour.cost             = Number(carFourPhp.cost);
        carFour.bhp                = Number(carFourPhp.bhp);
        carFour.handling        = Number(carFourPhp.handling);
        carFour.weight            = Number(carFourPhp.weight);
        carFour.reliability        = Number(carFourPhp.reliability);
        carFour.aerodynamics    = Number(carFourPhp.aerodynamics);
        carFour.total            = (carFour.bhp+carFour.handling+carFour.reliability+carFour.aerodynamics) - carFour.weight;
    }
    function statusHudUpdate(){
        _root.carNameMov.carNameText                     = carOne.make;
        _root.bankTotalMov.bankTotalText                 = "Bank total:"+" "+carOne.cost;
        _root.bhpStatMov.bhpStatText                     = carOne.bhp+" "+"Bhp";
        _root.bhpStatMov.statusBar._width                 = carOne.bhp;
        _root.controlStatMov.controlStatText             = carOne.handling+" "+"Control";
        _root.controlStatMov.statusBar._width             = carOne.handling;
        _root.weightStatMov.weightStatText                 = carOne.weight+" "+"Weight";
        _root.weightStatMov.statusBar._width             = carOne.weight;
        _root.reliabilityStatMov.reliabilityStatText     = carOne.reliability+" "+"Reliability";
        _root.reliabilityStatMov.statusBar._width         = carOne.reliability;
        _root.aeroStatMov.aeroStatText                     = carOne.aerodynamics+" "+"Aerodynamics";
        _root.aeroStatMov.statusBar._width                 = carOne.aerodynamics;
        _root.totalStatMov.totalStatText                = carOne.total+" "+"Total";
        _root.totalStatMov.statusBar._width                = carOne.total;
    }
}

Okay so on the timeline I have the arrow keys set up to cycle through the carGarage array pulling out the various strings “carOne” etc. I also have some stats bars set up showing each cars individual stats taken from an external php/mysql file.

What I want to do now is replace

_root.carNameMov.carNameText = carOne.make;

with somthing like

root.carNameMov.carNameText = carGarage[_global.arrayPlace].make;

So that when you cycle through the array the stats are dynamically changed. Only I can’t figure out how to write this part.

carGarage[_global.arrayPlace].make

Fingers crossed it’s going to be fairly simple, any help or ideas would be greatly appreciated.

Ta

Sigs