6 Replies Latest reply on Sep 14, 2006 7:17 PM by kglad

    storing objects in a Shared Object

    CogDev Level 1
      I have given up on trying to save my movie's data into a text file, and I'm using a shared object to store my data. In short, my problem is that when I store data and trace it right away, all seems fine, but when I go to retrieve it later, everything except strings and numbers return undefined.

      Here I explain in more detail:

      I have a shared object that contains an array of objects that contain information about a person:
      ID #
      Date of birth (date object)
      School (string)
      Tests ( this has an array of objects, each representing a set of test results)

      I have created a GUI for storing each subject's info, and for now, I have trace commands to show the contents of the SharedObject. When I flush the shared object, and then trace its contents, it shows up perfectly, but then when I go into the shared object later, all I see is the strings and the ID number. The date object and array return undefined.

      I have a hunch this might be because the SharedObject is storing pointers instead of the objects themselves, but I'm not sure how to fix that.
        • 1. Re: storing objects in a Shared Object
          CogDev Level 1
          Bumpy McBumperson
          • 2. Re: storing objects in a Shared Object
            Rothrock Level 5
            Haven't done much with shared objects, but my understanding is that they can hold all the Flash data types. I just did a simple test with directly storing a date in a shared object. I was only trying it in the testing environment, but it was persistent between quitting and starting up Flash. So I'm pretty sure you can store those.

            Sorry I can't help more. The whole AS2 notation is really impossible for me to follow and I'm not seeing where you are storing the dates.
            • 3. Re: storing objects in a Shared Object
              CogDev Level 1
              The thing is, I'm not saving the dates directly. I have my own class type called SubjectClass.

              Each SubjectClass has an ID, a date of birth, a string for school name, and an array for test records (this has another custom class in it)

              The code in my original post alters the SubjectClass object, and then saves that object into the SharedObject. So the date is being saved indrectly. It works for the id number, and for the school string, but the date and the array return undefined.
              • 4. Re: storing objects in a Shared Object
                kglad Adobe Community Professional & MVP
                you can't save an object in a shared object because the object doesn't exist outside your swf or as file.
                • 5. Re: storing objects in a Shared Object
                  CogDev Level 1
                  So you're saying that because the date exists as an object inside another object, that the SharedObject only contains a pointer?

                  If that's so, then how do I get the sharedObject to store the date, while maintaining its relationship to the subjectClass object I created?
                  • 6. Re: storing objects in a Shared Object
                    kglad Adobe Community Professional & MVP
                    i said, you can't store an object outside of flash because the object doesn't exist outside of flash.

                    you can store any and all details about the object and recreate it from those details, but you can't store the object.

                    so, you can store any property of your date object (for example, its day, month, year etc properties) and you can use those properties to create a date object that has the same properties.