A Flash Developer Resource Site

Results 1 to 7 of 7

Thread: Flah game doesn't always load scores

  1. #1
    Junior Member
    Join Date
    Apr 2011
    Posts
    25

    Flah game doesn't always load scores

    I have a Flash game I made and produced as a standalone projector that I put on a disc. The game consists of a series of trivia question tests, and at the end of each one the player is shown their score for that test, with the option to save their score under the name they can type into a dynamic text field. At any point in the game, they can type in their name and/or hit refresh and the score fields populate.
    The problem is, is that its not working consistently. Sometimes it will load the old scores, sometimes it won’t. The .sol files are saved in the Application Data folder, and they are still there even when the scores won’t load. If you don't close the program it loads every time, if you close it to take the disc out of the drive and reload it, it might load the scores, it might not; it seems to work (or not) completely at random. Even when the scores don’t appear, if you close it and reopen, it might load the scores that time (or not).

    One thing I can't understand is that for some reason the program is creating an extra series of folders that mirror the first part of the directory location (documents and settings\username\application data\ - which then appears again inside the macromedia folder in the Application Data folder). On top of that, each time the game is started, it creates a new sub folder where any new scores are saved - which again, sometimes it'll show old scores from the older folders, sometimes it wont; sometimes it'll show the new scores, sometimes it wont. It’s doing this on multiple computers.

    What's going on?

  2. #2
    Junior Member
    Join Date
    Apr 2011
    Posts
    25
    Could there be anything to the fact that the program is creating a new sub-folder to save the .sol files in, each times it's closed and run again? I just can't makes or tails of why or how it can sometimes lose track of these files that it can't correlate them to the program and populate the scores when called for, but then other times it will. If there's a reason it can't find these files one time, it should be consistently the case where it can't find it; not randomly locating and populating the data and other times not - right?
    Does anyone have any idea at all what could be causing this problem?

  3. #3
    When you know are. Son of Bryce's Avatar
    Join Date
    Aug 2002
    Location
    Los Angeles
    Posts
    838
    Because it sounds like it might be saving the shared object in different folders depending on how it reads the file structure, maybe it could help if you choose to save the SharedObject in a root folder, if you aren't doing that already. Like...

    PHP Code:
    SharedObject.getLocal("mySharedObjectID""/"); 
    You can try a sharedObject reader, it can help you debug the problem.

    http://www.sephiroth.it/python/solreader.php

    http://en.wikipedia.org/wiki/Local_s...s_and_toolkits

  4. #4
    Junior Member
    Join Date
    Apr 2011
    Posts
    25
    I'm pretty sure that's what this program uses. I'm not the original desginer, just the one responsible for updating it. When we had alpha tested it, everything worked fine; and I had made sure to test this part specifically, because of issues with the results. I eventually got it to work and at the time was working fine and consistantly.

    At any rate, this is the script that appears in an action frame, at the place in the game where the user can save their scores
    Code:
    //
    itemsReset ();
    testResults._visible = false;
    //
    function save_TF (record:String, field:String, now:Object, score:Object):Void
    {
    	var so:Object = Object (SharedObject.getLocal (record));
    	so.data.record = record;
    	so.data.field_TF = field;
    	so.data.now_TF = now;
    	so.data.score_TF = score;
    	so.flush ();
    }
    function load_TF (record:String, score_TF:Object):Object
    {
    	return Object (SharedObject.getLocal (record)).data.score_TF;
    }
    function getnow_TF (record:String, now_TF:Object):Object
    {
    	return Object (SharedObject.getLocal (record)).data.now_TF;
    }
    //
    saveFieldName_var = "General True/False Questions";
    //
    saveFieldValue_var = trueBox + " out of " + aQuestions.length + " makes " + Math.round (100 * trueBox / aQuestions.length) + "%";
    //
    myDate = new Date ();
    var monthArray:Array = new Array ("Jan", "Feb", "Mar", "Apr", "May", "June", "July", "Aug", "Sept", "Oct", "Nov", "Dec");
    var saveNowDate_var = (monthArray[myDate.getMonth ()] + "-" + myDate.getDate () + "-" + mydate.getFullYear ());
    if (Flag == 1)
    {
    	TestTime = "...time is not important!";
    }
    saveNowTime_var = TestTime;
    warningMsg2 = "To save the result\nenter your name and click SAVE button";
    //saveCount = 0;
    //
    
    this.save_mc.onPress = function ()
    {
    	if (saveRecordName_var == undefined)
    	{
    		warningMsg2 = "Enter your name, please!";
    	}
    	else
    	{
    		if (save_mc._visible = true)
    		{
    			loadFieldValue_txt.text = load_TF (saveRecordName_txt.text, saveFieldName_txt.text);
    			loadFieldDate_txt.text = getnow_TF (saveRecordName_txt.text, saveFieldName_txt.text);
    			save_TF (saveRecordName_txt.text, saveFieldName_txt.text, saveNowDate_var, saveFieldValue_txt.text);
    			warningMsg2 = "Your score is saved...";
    			save_mc._visible = false;
    			testResults._visible = true;
    				//reads any saved data from "test"
    //if "test" is changed the data is saved in a different location
    localInfo = SharedObject.getLocal("test");
    function saveScore() {
    	localInfo.data.score
    }
    		}
    		else
    		{
    			warningMsg2 = "Click OK to continue...";
    		}
    	}
    };
    
    this.onKeyDown = function() {
      if (Key.isDown(Key.ENTER)) {
    
    
    	if (saveRecordName_var == undefined)
    	{
    		warningMsg2 = "Enter your name, please!";
    	}
    	else
    	{
    		if (save_mc._visible = true)
    		{
    			loadFieldValue_txt.text = load_TF (saveRecordName_txt.text, saveFieldName_txt.text);
    			loadFieldDate_txt.text = getnow_TF (saveRecordName_txt.text, saveFieldName_txt.text);
    			save_TF (saveRecordName_txt.text, saveFieldName_txt.text, saveNowDate_var, saveFieldValue_txt.text);
    			warningMsg2 = "Your score is saved...";
    			save_mc._visible = false;
    			testResults._visible = true;
    		}
    		else
    		{
    			warningMsg2 = "Click OK to continue...";
    		}
    	}
    };
    }
    Key.addListener(this);
    There are multiple tests, with the results each all displayed on one page with separate fields for each test; so the variables determine which field the score is saved for, or populates to when the program is reopened and the score retrieved. This is the script on the results screen.
    Code:
    function load_TF (record:String, score_TF:Object):Object
    {
    	return Object (SharedObject.getLocal (record)).data.score_TF;
    }
    function load_GK (record:String, score_GK:Object):Object
    {
    	return Object (SharedObject.getLocal (record)).data.score_GK;
    }
    function load_AB (record:String, score_AB:Object):Object
    {
    	return Object (SharedObject.getLocal (record)).data.score_AB;
    }
    function load_PE (record:String, score_PE:Object):Object
    {
    	return Object (SharedObject.getLocal (record)).data.score_PE;
    }
    function load_SB (record:String, score_SB:Object):Object
    {
    	return Object (SharedObject.getLocal (record)).data.score_SB;
    }
    function load_CV (record:String, score_CV:Object):Object
    {
    	return Object (SharedObject.getLocal (record)).data.score_CV;
    }
    function load_CDT (record:String, score_CDT:Object):Object
    {
    	return Object (SharedObject.getLocal (record)).data.score_CDT;
    }
    function load_HM (record:String, score_HM:Object):Object
    {
    	return Object (SharedObject.getLocal (record)).data.score_HM;
    }
    function load_FL (record:String, score_FL:Object):Object
    {
    	return Object (SharedObject.getLocal (record)).data.score_FL;
    }
    function load_TV (record:String, score_TV:Object):Object
    {
    	return Object (SharedObject.getLocal (record)).data.score_TV;
    }
    //
    function getnow_TF (record:String, now_TF:Object):Object
    {
    	return Object (SharedObject.getLocal (record)).data.now_TF;
    }
    function getnow_GK (record:String, now_GK:Object):Object
    {
    	return Object (SharedObject.getLocal (record)).data.now_GK;
    }
    function getnow_AB (record:String, now_AB:Object):Object
    {
    	return Object (SharedObject.getLocal (record)).data.now_AB;
    }
    function getnow_PE (record:String, now_PE:Object):Object
    {
    	return Object (SharedObject.getLocal (record)).data.now_PE;
    }
    function getnow_SB (record:String, now_SB:Object):Object
    {
    	return Object (SharedObject.getLocal (record)).data.now_SB;
    }
    function getnow_CV (record:String, now_CV:Object):Object
    {
    	return Object (SharedObject.getLocal (record)).data.now_CV;
    }
    function getnow_CDT (record:String, now_CDT:Object):Object
    {
    	return Object (SharedObject.getLocal (record)).data.now_CDT;
    }
    function getnow_HM (record:String, now_HM:Object):Object
    {
    	return Object (SharedObject.getLocal (record)).data.now_HM;
    }
    function getnow_FL (record:String, now_FL:Object):Object
    {
    	return Object (SharedObject.getLocal (record)).data.now_FL;
    }
    function getnow_TV (record:String, now_TV:Object):Object
    {
    	return Object (SharedObject.getLocal (record)).data.now_TV;
    }
    //
    warningMsg2 = "Enter your name, please!";
    //this.saveRecordName_var = clear ();
    this.read_mc.onRelease = function ()
    {
    	warningMsg2 = clear ();
    	if (saveRecordName_var == "" | saveRecordName_var == undefined)
    	{
    		warningMsg2 = "Name doesn't exist,\nplease try again.";
    	}
    	else
    	{
    		readFieldValue_TF.text = load_TF (saveRecordName_txt.text, "General True/False Questions");
    		readFieldValue_GK.text = load_GK (saveRecordName_txt.text, "General Knowledge");
    		readFieldValue_AB.text = load_AB (saveRecordName_txt.text, "Air Brake");
    		readFieldValue_PE.text = load_PE (saveRecordName_txt.text, "Passenger Endorsement");
    		readFieldValue_SB.text = load_SB (saveRecordName_txt.text, "School Buses");
    		readFieldValue_CV.text = load_CV (saveRecordName_txt.text, "Combination Vehicles");
    		readFieldValue_CDT.text = load_CDT (saveRecordName_txt.text, "Doubles/Triples");
    		readFieldValue_HM.text = load_HM (saveRecordName_txt.text, "Hazardous Materials");
    		readFieldValue_FL.text = load_FL (saveRecordName_txt.text, "Fork Lift");
    		readFieldValue_TV.text = load_TV (saveRecordName_txt.text, "Tank Vehicles");
    		//
    		readFieldDate_TF.text = getnow_TF (saveRecordName_txt.text, "General True/False Questions");
    		readFieldDate_GK.text = getnow_GK (saveRecordName_txt.text, "General Knowledge");
    		readFieldDate_AB.text = getnow_AB (saveRecordName_txt.text, "Air Brake");
    		readFieldDate_PE.text = getnow_PE (saveRecordName_txt.text, "Passenger Endorsement");
    		readFieldDate_SB.text = getnow_SB (saveRecordName_txt.text, "School Buses");
    		readFieldDate_CV.text = getnow_CV (saveRecordName_txt.text, "Combination Vehicles");
    		readFieldDate_CDT.text = getnow_CDT (saveRecordName_txt.text, "Doubles/Triples");
    		readFieldDate_HM.text = getnow_HM (saveRecordName_txt.text, "Hazardous Materials");
    		readFieldDate_FL.text = getnow_FL (saveRecordName_txt.text, "Fork Lift");
    		readFieldDate_TV.text = getnow_TV (saveRecordName_txt.text, "Tank Vehicles");
    	}
    };
    this.onKeyDown = function() {
      if (Key.isDown(Key.ENTER)) {
    
    	warningMsg2 = clear ();
    	if (saveRecordName_var == "" | saveRecordName_var == undefined)
    	{
    		warningMsg2 = "Name doesn't exist,\nplease try again.";
    	}
    	else
    	{
    		readFieldValue_TF.text = load_TF (saveRecordName_txt.text, "General True/False Questions");
    		readFieldValue_GK.text = load_GK (saveRecordName_txt.text, "General Knowledge");
    		readFieldValue_AB.text = load_AB (saveRecordName_txt.text, "Air Brake");
    		readFieldValue_PE.text = load_PE (saveRecordName_txt.text, "Passenger Endorsement");
    		readFieldValue_SB.text = load_SB (saveRecordName_txt.text, "School Buses");
    		readFieldValue_CV.text = load_CV (saveRecordName_txt.text, "Combination Vehicles");
    		readFieldValue_CDT.text = load_CDT (saveRecordName_txt.text, "Doubles/Triples");
    		readFieldValue_HM.text = load_HM (saveRecordName_txt.text, "Hazardous Materials");
    		readFieldValue_FL.text = load_FL (saveRecordName_txt.text, "Fork Lift");
    		readFieldValue_TV.text = load_TV (saveRecordName_txt.text, "Tank Vehicles");
    		//
    		readFieldDate_TF.text = getnow_TF (saveRecordName_txt.text, "General True/False Questions");
    		readFieldDate_GK.text = getnow_GK (saveRecordName_txt.text, "General Knowledge");
    		readFieldDate_AB.text = getnow_AB (saveRecordName_txt.text, "Air Brake");
    		readFieldDate_PE.text = getnow_PE (saveRecordName_txt.text, "Passenger Endorsement");
    		readFieldDate_SB.text = getnow_SB (saveRecordName_txt.text, "School Buses");
    		readFieldDate_CV.text = getnow_CV (saveRecordName_txt.text, "Combination Vehicles");
    		readFieldDate_CDT.text = getnow_CDT (saveRecordName_txt.text, "Doubles/Triples");
    		readFieldDate_HM.text = getnow_HM (saveRecordName_txt.text, "Hazardous Materials");
    		readFieldDate_FL.text = getnow_FL (saveRecordName_txt.text, "Fork Lift");
    		readFieldDate_TV.text = getnow_TV (saveRecordName_txt.text, "Tank Vehicles");
    	}
    
    };
    }
    Key.addListener(this);

  5. #5
    Junior Member
    Join Date
    Apr 2011
    Posts
    25
    To be elaborate on how it's saving it; this is the full directory location that it's saving to:
    C:\Documents and Settings\("Computer Name")\Application Data\Macromedia\Flash Player\#SharedObjects\8XA842Q7\localhost\Documents and Settings\("computer name")\Application Data\IFViewer

    and then each time it runs, inside the IFViewer folder, it will create a new folder, with a random series of characters, which is where it will save the current data. I can't figure out why it's making such an elaborate path to save the files in, especially making copies of folders (in name anyway) of some of the root directories, like the computer user name folder and Documents and Settings, etc.
    And I could understand it not being able to find old scores if it's always making a new folder for new data, if it would never load old scores after closing and restarting the computer; that would at least make some sense, and then a specific target folder for the score files to be saved in would need to be explicitly declared in the script - but that's not the case. Sometimes it will still find an old score, while saving new files in a new folder.

    I'm told this worked fine with the previous version of the program, and nothing with the script has been changed; the issue I originally had was enabling embedded text on some of the text fields, as for some reason those setting wouldn't hold on some of them.

  6. #6
    When you know are. Son of Bryce's Avatar
    Join Date
    Aug 2002
    Location
    Los Angeles
    Posts
    838
    What I was saying before is that the getLocal() function should have a root directory like this...

    Actionscript Code:
    var so:Object = Object (SharedObject.getLocal ( record, "/" ));

    By saving the .sol in the root directory it wouldn't matter which directory the .swf is loaded, it'll always load the same .sol.

    Although with the problem you're describing, this may just make the .sol saved in...

    C:\Documents and Settings\("Computer Name")\Application Data\Macromedia\Flash Player\#SharedObjects\8XA842Q7\localhost\game.sol

    But the .swf should be loading the same .sol if you specify a path, maybe it's making random directories because it thinks that each time you load the swf its a different file or something.

  7. #7
    Junior Member
    Join Date
    Apr 2011
    Posts
    25
    I really wish I knew. I'm still kind of a novice at much of this programming; I know enough to navigate my way through the program, and recognize the general idea of what certain script is doing, like the script for saving the scores; and work on this program, getting it updated for a client certainly helped my education, learning how to fix certain parts that weren't working before I got to them - but the specific syntax of some of it, is a little out of my depth. I can understand enough of to know what it's doing, but not enough to understand exactly how it's doing it, or why this issue is occurring. Can you, or anyone, see in any of that script, anything that could be telling the program to behave outside the norm for this kind of function?

    The example you offered that would put it in a specific directory, look very close to what's there, but I don't know if the difference is necessarily the root of the problem; especially where previous versions of this program with this script as it still appears, functioning fine.

    What really perplexes me, is that it creates these extra sub-folders in the Application Data sub directory; duplicating some of the names of the root folders, rather than just accessing that directory. And once in final folder that it saves to, it still goes one step further, creating a new folder the .sol files are saved in; applying to that folder a name made of random characters - and then each time the program starts, it'll do it again, making a new folder to save the new scores to; when to my knowledge it should all be saved in the same folder, the new scores overwriting the old. All I can figure is that, somehow that lack of continuity between saved and accessed directories is what's causing this problem. But then I can't figure out why the program can sometimes find the score; it should never be able to find them if that was the full problem.

    ...I'm just at a total loss to understand what's going on.

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