A Flash Developer Resource Site

Results 1 to 8 of 8

Thread: Can some one help

  1. #1
    Senior Member
    Join Date
    Apr 2009
    Posts
    138

    Can some one help

    I am wondering if any one here is pretty good with SharedObjects. I am trying to save a game and it isn't working. Would any one help? Id hate to post the fla, and have 300 people veiw with out a response. if you have like 15 minutes to help me post here please.

  2. #2
    Pumpkin Carving 2008 ImprisonedPride's Avatar
    Join Date
    Apr 2006
    Location
    Grand Rapids MI
    Posts
    2,378
    Please do not create a second thread to advertise your other one. You said it has 300 views? Maybe you should be patient and give people a few days to think of some advice.
    The 'Boose':
    ASUS Sabertooth P67 TUF
    Intel Core i7-2600K Quad-Core Sandy Bridge 3.4GHz Overclocked to 4.2GHz
    8GB G.Skill Ripjaws 1600 DDR3
    ASUS ENGTX550 TI DC/DI/1GD5 GeForce GTX 550 Ti (Fermi) 1GB 1GDDR5 (Overclocked to 1.1GHz)
    New addition: OCZ Vertex 240GB SATA III SSD
    WEI Score: 7.6

  3. #3
    Senior Member
    Join Date
    Apr 2009
    Posts
    138
    Thank you for your very quick and polite response.

    This is a diffrent problem then the other ones I posted.

    But thanks for asking what the problem was. >_<

  4. #4
    Senior Member
    Join Date
    Apr 2009
    Posts
    138
    this is what is declared on the first frame

    Actionscript Code:
    _level0.looptmp = [slot1=["mana", "static", "mana_fmt", "Comic-12", false, "advanced", 200, -100, true, 10, true], slot2=["manacurrent", "dynamic", "manacurrent_fmt", null, false, "advanced", 200, -100, false, null, false], slot3=["healthcurrent", "dynamic", "healthcurrent_fmt", null, false, "advanced", 200, -100, false, null, false], slot4=["expcurrent", "dynamic", "expcurrent_fmt", null, false, "advanced", 200, -100, false, null, false], slot5=["health", "static", "health_fmt", "Comic-12", false, "advanced", 200, -100, true, 10, true], slot6=["exp1", "static", "exp_fmt", "Comic-12", false, "advanced", 200, -100, true, 10, true], slot7=["idbinfo", "dynamic", "idbinfo_fmt", "Comic-12", false, "advanced", 200, -100, false, null, false], slot8=["new_game", "static", "new_game_fmt", "Comic Sans Ms", false, "advanced", 0, 0, false, 20, true]];
    _level0.saveslot = [slot1=["", 0, "dce"]];
    _level0.loadslot = [slot1=["", "", ""]];
    _level0.itemdatabase = [slot1=["rod", "rod1", 0, 0, 0, 80, 0, 1, 1, "", 0, " a aa"], slot2=["tadpoles", "food", 0.3, 3, 3, 3, 1, 0, 1, "eat", 0, "The delicious tadpoles healed you by 3hp!"], slot3=["frog", "frog1", 0.5, 3.5, 4, 5, 1, 0, 1, "eat", 1, "Baby Frog: + 1 Mana, + 4 Health"], slot4=["seaweed", "food", 0.2, 2.8, -6, 0, 1, 0, 1, "eat", 3, "The seaweed is discusting: +3 Mana, -6 Health!! - YUCK"]];
    _level0.currentitem = [slot1=["", "", 0, 0, 0, 0, 0, 0, 0, "", 0, ""]];
    _level0.playerpackempty = [slot1=["", "", 0, 0, 0, 0, 0, 0, 0, "", 0, ""]];
    _level0.playerpack = [slot1=["", "", 0, 0, 0, 0, 0, 0, 0, "", 0, ""], slot2=["", "", 0, 0, 0, 0, 0, 0, 0, "", 0, ""], slot3=["", "", 0, 0, 0, 0, 0, 0, 0, "", 0, ""], slot4=["", "", 0, 0, 0, 0, 0, 0, 0, "", 0, ""], slot5=["", "", 0, 0, 0, 0, 0, 0, 0, "", 0, ""], slot6=["", "", 0, 0, 0, 0, 0, 0, 0, "", 0, ""], slot7=["", "", 0, 0, 0, 0, 0, 0, 0, "", 0, ""], slot8=["", "", 0, 0, 0, 0, 0, 0, 0, "", 0, ""], slot9=["", "", 0, 0, 0, 0, 0, 0, 0, "", 0, ""], slot10=["", "", 0, 0, 0, 0, 0, 0, 0, "", 0, ""], slot11=["", "", 0, 0, 0, 0, 0, 0, 0, "", 0, ""], slot12=["", "", 0, 0, 0, 0, 0, 0, 0, "", 0, ""], slot13=["", "", 0, 0, 0, 0, 0, 0, 0, "", 0, ""], slot14=["", "", 0, 0, 0, 0, 0, 0, 0, "", 0, ""]];
    _level0.playerpack[0] = _level0.itemdatabase[0];
    _level0.playerpack[1] = _level0.itemdatabase[2];
    _level0.currentframe = "";
    var currentmanavar:Number = 10;
    var totalmanavar:Number = 20;
    var currenthealthvar:Number = 250;
    var totalhealthvar:Number = 300;
    var currentexpvar:Number = 72;
    var totalexpvar:Number = 350;
    var tmploopvar004_2 :Boolean = false;
    var emptyslot:Number;
    menu_btns_all_x = 375;
    this.mm_txtcreate = [
        slot1=[
    /*Instance*/     "mm_newgame",
    /*Type*/         "static",
    /*Format Inst.*/ "mm_newgame_fmt",
    /*Font*/         "Dj Gross",
    /*Selectable*/   true,
    /*AntiAlias*/    "advanced",
    /*Thickness*/    200,
    /*Sharpness*/    -100,
    /*Embed Font*/   true,
    /*size*/         20,
    /*Bold*/         true,
    /*Border*/       false,
    /*Label*/        "New Game"],
            slot2=[
    /*Instance*/     "mm_loadgame",
    /*Type*/         "static",
    /*Format Inst.*/ "mm_loadgame_fmt",
    /*Font*/         "Dj Gross",
    /*Selectable*/   true,
    /*AntiAlias*/    "advanced",
    /*Thickness*/    200,
    /*Sharpness*/    -100,
    /*Embed Font*/   true,
    /*size*/         20,
    /*Bold*/         true,
    /*Border*/       false,
    /*Label*/        "Load Game"],
            slot3=[
    /*Instance*/     "mm_savegame",
    /*Type*/         "static",
    /*Format Inst.*/ "mm_savegame_fmt",
    /*Font*/         "Dj Gross",
    /*Selectable*/   true,
    /*AntiAlias*/    "advanced",
    /*Thickness*/    200,
    /*Sharpness*/    -100,
    /*Embed Font*/   true,
    /*size*/         20,
    /*Bold*/         true,
    /*Border*/       false,
    /*Label*/        "Save Game"],
                    slot4=[
    /*Instance*/     "mm_options",
    /*Type*/         "static",
    /*Format Inst.*/ "mm_options_fmt",
    /*Font*/         "Dj Gross",
    /*Selectable*/   true,
    /*AntiAlias*/    "advanced",
    /*Thickness*/    200,
    /*Sharpness*/    -100,
    /*Embed Font*/   true,
    /*size*/         20,
    /*Bold*/         true,
    /*Border*/       false,
    /*Label*/        "Options"],
                            slot5=[
    /*Instance*/     "mm_credits",
    /*Type*/         "static",
    /*Format Inst.*/ "mm_credits_fmt",
    /*Font*/         "Dj Gross",
    /*Selectable*/   true,
    /*AntiAlias*/    "advanced",
    /*Thickness*/    200,
    /*Sharpness*/    -100,
    /*Embed Font*/   true,
    /*size*/         20,
    /*Bold*/         true,
    /*Border*/       false,
    /*Label*/        "Credits"],
                            slot6=[
    /*Instance*/     "mm_title",
    /*Type*/         "static",
    /*Format Inst.*/ "mm_title_fmt",
    /*Font*/         "Gesso",
    /*Selectable*/   false,
    /*AntiAlias*/    "advanced",
    /*Thickness*/    200,
    /*Sharpness*/    -100,
    /*Embed Font*/   true,
    /*size*/         50,
    /*Bold*/         true,
    /*Border*/       false,
    /*Label*/        "Evil Premonitions"
            ],
                            slot7=[
    /*Instance*/     "mm_credits",
    /*Type*/         "static",
    /*Format Inst.*/ "mm_credits_fmt",
    /*Font*/         "Dj Gross",
    /*Selectable*/   true,
    /*AntiAlias*/    "advanced",
    /*Thickness*/    200,
    /*Sharpness*/    -100,
    /*Embed Font*/   true,
    /*size*/         20,
    /*Bold*/         true,
    /*Border*/       false,
    /*Label*/        "Credits"],
                            slot8=[
    /*Instance*/     "lgm_title",
    /*Type*/         "static",
    /*Format Inst.*/ "lgm_title_fmt",
    /*Font*/         "Dj Gross",
    /*Selectable*/   false,
    /*AntiAlias*/    "advanced",
    /*Thickness*/    200,
    /*Sharpness*/    -100,
    /*Embed Font*/   true,
    /*size*/         25,
    /*Bold*/         true,
    /*Border*/       false,
    /*Label*/        "Load Game"
            ],
                            slot8=[
    /*Instance*/     "sgm_title",
    /*Type*/         "static",
    /*Format Inst.*/ "sgm_title_fmt",
    /*Font*/         "Dj Gross",
    /*Selectable*/   false,
    /*AntiAlias*/    "advanced",
    /*Thickness*/    200,
    /*Sharpness*/    -100,
    /*Embed Font*/   true,
    /*size*/         25,
    /*Bold*/         true,
    /*Border*/       false,
    /*Label*/        "Save Game"
            ]];
    Last edited by brickhouse420; 01-03-2011 at 11:20 PM.

  5. #5
    Senior Member
    Join Date
    Apr 2009
    Posts
    138
    This file is loaded withing a another movie inside a movie clip called container_mc.
    The first frame declares some arrays.
    This is whats on the second frame.
    as you can see I attach a movie called mm_ui.
    this has a blank first frame with some listeners for loadgame function, save game delete game and return to menu. then the second frame calls the populatesaveloadlist function and has a list (mylist) in it, and a load game, del game and return to menu button. the third frame has save game, delete game, return to menu. and also calls populatesaveloadlist function.

    When I run this code, and click save game, and enter a value in the textbox (as a label) it will be added to the list component, but I have a loop in the savegame function and it seems to return that the SharedObject is undefined, when I define it. All this code was working fine when it was its only movie clip. But I made it load into another movie clip and changed some of the settings around like _level0.container_mc.mm_ch.mm_ui.mylist (to get to the list). and it doesnt seem to work quite the same. if youw ant the fla. or the swf let me know.

    \/ CODE on first frame

    Actionscript Code:
    this.attachMovie("mm_bgimg", "mm_bg", 0, {_x:0, _y:0});
    this.createEmptyMovieClip("mm_ng", 1, {_x:0, _y:0});
    this.createEmptyMovieClip("mm_lg", 2, {_x:0, _y:40});
    this.createEmptyMovieClip("mm_sg", 3, {_x:0, _y:80});
    this.createEmptyMovieClip("mm_op", 4, {_x:0, _y:120});
    this.createEmptyMovieClip("mm_cr", 5, {_x:0, _y:160});


    var mm_newgame_fmt:TextFormat = new TextFormat();
    var mm_loadgame_fmt:TextFormat = new TextFormat();
    var mm_savegame_fmt:TextFormat = new TextFormat();
    var mm_options_fmt:TextFormat = new TextFormat();
    var mm_credits_fmt:TextFormat = new TextFormat();
    var mm_title_fmt:TextFormat = new TextFormat();



    var mm_newgame:TextField = this.mm_ng.createTextField(mm_txtcreate[0][0], 2001, 10, menu_btns_all_x+0, 146, 30);
    var mm_loadgame:TextField = this.mm_lg.createTextField(mm_txtcreate[1][0], 2002, 10, menu_btns_all_x+30, 152, 30);
    var mm_savegame:TextField = this.mm_sg.createTextField(mm_txtcreate[2][0], 2003, 10, menu_btns_all_x+60, 155, 30);
    var mm_options:TextField = this.mm_op.createTextField(mm_txtcreate[3][0], 2004, 10, menu_btns_all_x+90, 120, 30);
    var mm_credits:TextField = this.mm_cr.createTextField(mm_txtcreate[4][0], 2005, 10, menu_btns_all_x+120, 120, 30);
    var mm_title:TextField = this.createTextField(mm_title, 2006, 138, 0, 555, 67);


    for (v=0; v<6; v++) {
        this[mm_txtcreate[v][0]].type = mm_txtcreate[v][0];
        this[mm_txtcreate[v][2]].font = mm_txtcreate[v][3];
        this[mm_txtcreate[v][0]].selectable = mm_txtcreate[v][4];
        this[mm_txtcreate[v][0]].antiAliasType = mm_txtcreate[0][5];
        this[mm_txtcreate[v][0]].thickness = mm_txtcreate[v][6];
        this[mm_txtcreate[v][0]].sharpness = mm_txtcreate[v][7];
        this[mm_txtcreate[v][0]].embedFonts = mm_txtcreate[v][8];
        this[mm_txtcreate[v][2]].size = mm_txtcreate[v][9];
        this[mm_txtcreate[v][2]].bold = mm_txtcreate[v][10];
        this[mm_txtcreate[v][0]].border = mm_txtcreate[v][11];
        this[mm_txtcreate[v][2]].color = 0xffffff;
        this[mm_txtcreate[v][0]].text = mm_txtcreate[v][12];
        this[mm_txtcreate[v][0]].setTextFormat(this[mm_txtcreate[v][2]]);
    }


    mm_gotostop = function () {
        gotoAndStop(3);
        remove_mm_btns();
        if (_level0.currentframe != "") {
            this.attachMovie("mm_content_holder", "mm_ch", 1, {_x:28, _y:97});
            this.mm_ch.attachMovie("mm_ui", "mm_ui", 2, {_x:35, _y:80});
        }
        if (_level0.currentframe=="mm_lg") {
           
            _level0.lgm_title_fmt = new TextFormat();
            var lgm_title:TextField = this.createTextField("lgm_title", 2007, 236.5, 105, 180, 35);
            for (v=7; v<8; v++) {
                this[mm_txtcreate[v][0]].type = mm_txtcreate[v][0];
                this[mm_txtcreate[v][2]].font = mm_txtcreate[v][3];
                this[mm_txtcreate[v][0]].selectable = mm_txtcreate[v][4];
                this[mm_txtcreate[v][0]].antiAliasType = mm_txtcreate[0][5];
                this[mm_txtcreate[v][0]].thickness = mm_txtcreate[v][6];
                this[mm_txtcreate[v][0]].sharpness = mm_txtcreate[v][7];
                this[mm_txtcreate[v][0]].embedFonts = mm_txtcreate[v][8];
                this[mm_txtcreate[v][2]].size = mm_txtcreate[v][9];
                this[mm_txtcreate[v][2]].bold = mm_txtcreate[v][10];
                this[mm_txtcreate[v][0]].border = mm_txtcreate[v][11];
                this[mm_txtcreate[v][2]].color = 0xffffff;
                this[mm_txtcreate[v][0]].text = mm_txtcreate[v][12];
                this[mm_txtcreate[v][0]].setTextFormat(this[mm_txtcreate[v][2]]);
            }
            temp001_frame = 2;
        }
        if (_level0.currentframe=="mm_sg") {
           
            _level0.sgm_title_fmt = new TextFormat();
            var sgm_title:TextField = this.createTextField("sgm_title", 2008, 236.5, 105, 180, 35);
            for (v=8; v<9; v++) {
                this[mm_txtcreate[v][0]].type = mm_txtcreate[v][0];
                this[mm_txtcreate[v][2]].font = mm_txtcreate[v][3];
                this[mm_txtcreate[v][0]].selectable = mm_txtcreate[v][4];
                this[mm_txtcreate[v][0]].antiAliasType = mm_txtcreate[0][5];
                this[mm_txtcreate[v][0]].thickness = mm_txtcreate[v][6];
                this[mm_txtcreate[v][0]].sharpness = mm_txtcreate[v][7];
                this[mm_txtcreate[v][0]].embedFonts = mm_txtcreate[v][8];
                this[mm_txtcreate[v][2]].size = mm_txtcreate[v][9];
                this[mm_txtcreate[v][2]].bold = mm_txtcreate[v][10];
                this[mm_txtcreate[v][0]].border = mm_txtcreate[v][11];
                this[mm_txtcreate[v][2]].color = 0xffffff;
                this[mm_txtcreate[v][0]].text = mm_txtcreate[v][12];
                this[mm_txtcreate[v][0]].setTextFormat(this[mm_txtcreate[v][2]]);
            }
            temp001_frame = 3;
        }
        mm_ch.mm_ui.gotoAndStop(temp001_frame);
    };
    mm_ng.onRollOver = function() {
        mm_newgame_fmt.color = 0x660005;
        mm_newgame.setTextFormat(mm_newgame_fmt);
        mm_ng.onRelease = function() {
            mm_newgame_fmt.color = 0x660005;
            mm_newgame.setTextFormat(mm_newgame_fmt);
            _level0.currentframe = "mm_ng";
        };
    };
    mm_ng.onRollOut = function() {
        mm_newgame_fmt.color = 0xffffff;
        mm_newgame.setTextFormat(mm_newgame_fmt);
    };


    mm_lg.onRollOver = function() {
        mm_loadgame_fmt.color = 0x660005;
        mm_loadgame.setTextFormat(mm_loadgame_fmt);
        mm_lg.onRelease = function() {
            mm_loadgame_fmt.color = 0x660005;
            mm_loadgame.setTextFormat(mm_loadgame_fmt);
            _level0.currentframe = "mm_lg";
            mm_gotostop();
        };
    };
    mm_lg.onRollOut = function() {
        mm_loadgame_fmt.color = 0xffffff;
        mm_loadgame.setTextFormat(mm_loadgame_fmt);
    };
    mm_lg.onDragOut = function() {
        mm_loadgame_fmt.color = 0xffffff;
        mm_loadgame.setTextFormat(mm_loadgame_fmt);
    };
    mm_lg.onDragOver = function() {
        mm_loadgame_fmt.color = 0x660005;
        mm_loadgame.setTextFormat(mm_loadgame_fmt);
    };


    mm_sg.onRollOver = function() {
        mm_savegame_fmt.color = 0x660005;
        mm_savegame.setTextFormat(mm_savegame_fmt);
        mm_sg.onRelease = function() {
            mm_savegame_fmt.color = 0x660005;
            mm_savegame.setTextFormat(mm_savegame_fmt);
            _level0.currentframe = "mm_sg";
            mm_gotostop();
        };
    };
    mm_sg.onRollOut = function() {
        mm_savegame_fmt.color = 0xffffff;
        mm_savegame.setTextFormat(mm_savegame_fmt);
    };


    mm_op.onRollOver = function() {
        mm_options_fmt.color = 0x660005;
        mm_options.setTextFormat(mm_options_fmt);
        mm_op.onRelease = function() {
            mm_options_fmt.color = 0x660005;
            mm_options.setTextFormat(mm_options_fmt);
            _level0.currentframe = "mm_op";
        };
    };
    mm_op.onRollOut = function() {
        mm_options_fmt.color = 0xffffff;
        mm_options.setTextFormat(mm_options_fmt);
    };
    mm_cr.onRollOver = function() {
        mm_credits_fmt.color = 0x660005;
        mm_credits.setTextFormat(mm_credits_fmt);
        mm_cr.onRelease = function() {
            mm_credits_fmt.color = 0x660005;
            mm_credits.setTextFormat(mm_credits_fmt);
            _level0.currentframe = "mm_cr";
        };
    };
    mm_cr.onRollOut = function() {
        mm_credits_fmt.color = 0xffffff;
        mm_credits.setTextFormat(mm_credits_fmt);
    };


    remove_mm_btns = function () {
        mm_newgame.removeTextField();
        mm_loadgame.removeTextField();
        mm_savegame.removeTextField();
        mm_options.removeTextField();
        mm_credits.removeTextField();
    };




    loadgame = function () {
        trace("Load Game Initiated");
        trace("VARIABLE CHECK:: idxdel = "+idxdel);
        _level0.localInfo = SharedObject.getLocal("savedgame"+idxdel);
        if (_level0.localInfo.data.score == undefined) {
            trace("nothing saved");
        } else {
            _level0.loadslot = _level0.localInfo.data.score;
            trace("Saved Data is:"+_level0.loadslot[0][0]);
        }
    };



    delgame = function () {
        trace("DELETE GAME INITILIZED");
        trace("VARIABLE CHECK:: idxdel = "+idxdel);
        _level0.localInfo = SharedObject.getLocal("savedgame"+idxdel);
        _level0.localInfo.clear();
            _level0.container_mc.mm_ch.mm_ui.mylist.removeItemAt(_level0.container_mc.mm_ch.mm_ui.mylist.selectedIndex);
           
        for (var tmploopvar002:Number = idxdel; tmploopvar002<30; tmploopvar002++) {
            _level0.localInfo = SharedObject.getLocal("savedgame"+(tmploopvar002+1));
            _level0.tmparray01 = _level0.localInfo.data.score;
            _level0.localInfo = SharedObject.getLocal("savedgame"+tmploopvar002);
            _level0.localInfo.data.score = _level0.tmparray01
           
           
                    if (tmploopvar002 == 29) {
                        trace("REMOVING LIST ITEMS AFTER UPDATE FROM DELETE");
                        _level0.container_mc.mm_ch.mm_ui.mylist.removeAll();
                for (var tmploopvar003:Number  = 0; tmploopvar003<30; tmploopvar003++) {
                    _level0.localInfo = SharedObject.getLocal("savedgame"+tmploopvar003);
                    //localInfo.clear();
                    if (_level0.localInfo.data.score != undefined) {
                        _level0.container_mc.mm_ch.mm_ui.mylist.addItem({label:""+_level0.localInfo.data.score[0][0]+" #"+tmploopvar003, idxdel:tmploopvar003});
                    }
                    if (tmploopvar003 == 29) {
                        _level0.container_mc.mm_ch.mm_ui.mylist.sortItemsBy(idxdel, "DESC");
                    }
                }
            }

        }
    };

    savegame = function () {
        for (tmploopvar004= 0; tmploopvar004<30; tmploopvar004++) {
            _level0.localInfo = SharedObject.getLocal("savedgame"+tmploopvar004);
            if (_level0.localInfo.data.score == undefined) {
                if (!tmploopvar004_2) {
                    emptyslot = tmploopvar004;
                    tmploopvar004_2 = true;
                    tmploopvar004 = 31;
                }
                if (tmploopvar004 == 31) {
                    tmploopvar004_2 = false;
                    _level0.saveslot[0][1] = mm_ch.mm_ui.savegamelabel.text;
                    trace ("Save slot's empty slot (according to emptyslot): "+emptyslot);
                    _level0.saveslot[0][0] = emptyslot;
                    trace ("Save slot's empty slot (according to array): "+emptyslot);
                    if (emptyslot<30) {
                        _level0.localInfo = SharedObject.getLocal("savedgame"+_level0.saveslot[0][0]);
                        _level0.container_mc.mm_ch.mm_ui.mylist.addItemAt(0, {label:""+_level0.saveslot[0][1]+" #"+emptyslot, idxdel:_level0.saveslot[0][0]});
                        _level0.localInfo.data.score = _level0.saveslot;
                        trace ("Save Slot: "+_level0.saveslot);
                        trace ("Local info: "+_level0.localInfo.data.score);
                    } else {
                        savegamelabel.text = "Max 30 saves reached!";
                    }
                }
            }
        }
    };



    populatesaveloadlist = function () {
        //mm_ch.mm_ui.mylist.removeAll();
        for (tmploopvar001 = 0; tmploopvar001<30; tmploopvar001++) {
            _level0.localInfo = SharedObject.getLocal("savedgame"+tmploopvar001);
                trace(_level0.localInfo.data.score);
           
            if (_level0.localInfo.data.score != undefined) {
                _level0.container_mc.mm_ch.mm_ui.mylist.addItemAt(0,{label:""+_level0.localInfo.data.score[0][1]+" #"+tmploopvar001, idxdel:tmploopvar001});
            }
            if (tmploopvar001 == 29) {
                _level0.container_mc.mm_ch.mm_ui.mylist.sortItemsBy(idxdel, "DESC");
            }
        }
    };


    return_to_mm = function(){
        _level0.container_mc.mm_ch.mm_ui.mylist.removeAll();
        _level0.container_mc.gotoAndStop (2);
    }
    stop();

  6. #6
    Pumpkin Carving 2008 ImprisonedPride's Avatar
    Join Date
    Apr 2006
    Location
    Grand Rapids MI
    Posts
    2,378
    Quote Originally Posted by brickhouse420 View Post
    Thank you for your very quick and polite response.

    This is a diffrent problem then the other ones I posted.

    But thanks for asking what the problem was. >_<
    So your problem is different, but you're posting about the same topic: shared objects. Instead of posting multiple topics with the same concern, perhaps once one of your threads gets a response it might shed some light and help you better understand shared objects in general. Your initiative hasn't gone unnoticed, but posting multiple threads about the same thing won't get you any quicker responses. If someone knew about your other thread with knowledge of shared objects then they would have tried to help.
    The 'Boose':
    ASUS Sabertooth P67 TUF
    Intel Core i7-2600K Quad-Core Sandy Bridge 3.4GHz Overclocked to 4.2GHz
    8GB G.Skill Ripjaws 1600 DDR3
    ASUS ENGTX550 TI DC/DI/1GD5 GeForce GTX 550 Ti (Fermi) 1GB 1GDDR5 (Overclocked to 1.1GHz)
    New addition: OCZ Vertex 240GB SATA III SSD
    WEI Score: 7.6

  7. #7
    Senior Member
    Join Date
    Apr 2009
    Posts
    138
    I already solved my other problem. And this one is different. I am assuming this is more of an error with some sort of typo or loop set up wrong. Becuase I know how to save and load information. In a file that wasn't loaded into anything I had everything working fine but once I put the code in here, and changed some of the _level0. thats when things got messed up.

  8. #8
    Senior Member
    Join Date
    Apr 2009
    Posts
    138
    Quote Originally Posted by brickhouse420 View Post
    I already solved my other problem. And this one is different. I am assuming this is more of an error with some sort of typo or loop set up wrong. Becuase I know how to save and load information. In a file that wasn't loaded into anything I had everything working fine but once I put the code in here, and changed some of the _level0. thats when things got messed up.
    anyways, to any one who is actually willing to post and help me. here is the files.

    http://uploaded.to/file/c65b3l#

    everytime you upload any of the actionscript files you need to recompile game. and run preload to run the .game.swf (it will load external)

    Also wanted to add that I have a file with 3 movieclips. One says delgame, one says savegame and the other says loadgame. (instance and also text in the movieclip)
    then there is a list (mylist) and a input box.

    the code on this fla (e:\saveinfo.fla)

    is all on the first frame.

    actionscript Code:
    _level0.looptmp = [slot1=["", 0, "dce"]];
    _level0.looptmp2 = [slot1=["", "", ""]];
    var ese:Boolean = false;
    var emptyslot:Number;
    //Initalizes
    for (var e = 0; e<30; e++) {
        var localInfo:SharedObject = SharedObject.getLocal("savedgame"+e);
    //localInfo.clear();
        trace("Saved Var #"+e+" = "+localInfo.data.score);
        if (localInfo.data.score != undefined) {
            mylist.addItem({label:""+localInfo.data.score[0][0]+" #"+e, idxdel:e});
        }
        if (e == 29) {
            mylist.sortItemsBy(idxdel, "DESC");
        }
    }
    function saveScore(tmpvar) {
        if (emptyslot<30) {
            var localInfo:SharedObject = SharedObject.getLocal("savedgame"+tmpvar[0][1]);
            mylist.addItemAt(0, {label:""+tmpvar[0][0]+" #"+emptyslot, idxdel:tmpvar[0][1]});
            localInfo.data.score = tmpvar;
            //localInfo.data.score = emptyslot;
        } else {
            savegamelabel.text = "Max 30 saves reached!";
        }
    }
    savegame.onRelease = function() {
        for (var e = 0; e<30; e++) {
            trace(e);
            var localInfo:SharedObject = SharedObject.getLocal("savedgame"+e);
            if (localInfo.data.score == undefined) {
                if (!ese2) {
                    trace("empty: "+e);
                    emptyslot = e;
                    ese2 = true;
                    e = 31;
                }
                if (e == 31) {
                    ese2 = false;
                    trace("Save Game btn: "+emptyslot);
                    //_level0.looptmp[0][0] = savegamelabel.text;
                    _level0.looptmp[0][0] = emptyslot;
                    _level0.looptmp[0][1] = emptyslot;
                    trace(_level0.looptmp);
                    saveScore(_level0.looptmp);
                }
            }
        }
    };
    loadgame.onRelease = function() {
        trace(mylist.selectedIndex);
        var localInfo:SharedObject = SharedObject.getLocal("savedgame"+idxdel);
        if (localInfo.data.score == undefined) {
            abc.text = "nothing saved";
        } else {
            _level0.looptmp2 = localInfo.data.score;
            trace(_level0.looptmp2[0][0]);
        }
    };
    delgame.onRelease = function() {
        var localInfo:SharedObject = SharedObject.getLocal("savedgame"+idxdel);
        localInfo.clear();
        mylist.removeItemAt(mylist.selectedIndex)
        for (var e2:Number = idxdel; e2<30; e2++) {
            var localInfo:SharedObject = SharedObject.getLocal("savedgame"+(e2+1));
            _level0.tmparray01 = localInfo.data.score;
            var localInfo:SharedObject = SharedObject.getLocal("savedgame"+e2);
            localInfo.data.score = _level0.tmparray01;     
                    if (e2 == 29) {
                        mylist.removeAll();
                for (var e:Number  = 0; e<30; e++) {
                    var localInfo:SharedObject = SharedObject.getLocal("savedgame"+e);
                    //localInfo.clear();
                    if (localInfo.data.score != undefined) {
                        mylist.addItem({label:""+localInfo.data.score[0][0]+" #"+e, idxdel:e});
                    }
                    if (e == 29) {
                        trace(localInfo.data.score);
                        mylist.sortItemsBy(idxdel, "DESC");
                    }
                }
            }

        }
    };
    mylist.change = function(evt:Object) {
        idxdel = evt.target.selectedItem.idxdel;
    };
    mylist.addEventListener("change", mylist);

    this code works great, but once I saved the file as saveinfo2.fla it no longer worked. only adding info to the mylist as index 0, meaning that every time i checked the shared object, it came back undefined. when I save it back to saveinfo.fla it works. I don't understand this? It should be working for any flash file!
    Last edited by brickhouse420; 01-04-2011 at 02:37 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center