Dear fellow geeks,

I'm creating a video game where the user can have multiple games. Each game has a few vars, being the current level, the name of the game, high scores per level etc.

For instance, I could have two games (the shared object is called "cookie" in this example) with this structure:

cookie.Data{
g1{ //game 1
level = 2;
high0 = 409 //high scores for levels 0-2
high1 = 237
high2 = 566
HP = 61
mana = 15
}
g2{ // game 2
level = 1
high0 = 255
high1 = 488
HP = 28
mana = 44
}
}

Problem: I can't seem to find the right syntax to create this structure!

I have tried this, but it does not work:

Actionscript Code:
function newGame():Void{

    if(cookie.data.gameCount > 0){ // if there already are games
        cookie.data.gameCount ++;
    }
    else{ // if this is the first new game
        cookie.data.gameCount = 1;
    }
    trace(cookie.data.gameCount);       // returns the correct number :)

    var current:Number= cookie.data.gameCount;
    // 'number' corresponding with most recently created game

    cookie.data["g"+_root.current] = new Object;
    // create directory for current game

    cookie.data["g"+_root.current].lvl = new Number(0);
    // sets new game level to 0; I think the error is somewhere here, since tracing this returns undefined!

    cookie.flush();
    // saves data locally to user's computer

    trace(cookie.data.g19.lvl);
    //the 19 can be replaced by any number, as long as it is between 0 and _root.current.
    // this trace() somehow returns "undefined" ?????

    //--------
    /*so, the cookie consists of:
            cookie.data{
                gamecount :Number;
                g1{
                    lvl:Number
                    >room for more vars here<
                }g2 (optional){
                    idem g1
                }etc.
            }*/

    //--------

    loadGame(current); // you can imagine what this does ;)
}

Can anybody help me, please?
thanks a bunch