7 Replies Latest reply on Feb 9, 2007 7:45 AM by mxc

    problem with Shared Object

    mxc Level 1
      Hi flash developers,

      I have a problem with getting the value of a variable saved in a shared object.
      I am saving two variables called evt_obj.target and evt_obj.target .text
      It is only the variable evt_obj.target which is giving me problems.
      When saved my trace shows the variable is correctly sent to the shared object but when retrieved it just shows up as undefined.
      Any ideas?

      thanks
      Michael
        • 1. Re: problem with Shared Object
          Jan-Paul K.
          what type of objects are "evt_obj.target" and "evt_obj.target.text"?
          It looks as if the target is an textfield instance (so you should give it a name that indicates it is a textfield).

          Are you saying you get the value of "evt_obj.target.text" but "evt_obj.target" returns undefined? I would say this is impossible if both values are requested at the same time. An objects instance variable can not be accessible before the object itself is existing.
          • 2. Re: problem with Shared Object
            mxc Level 1
            Hi, thanks for your answer.

            The evt_obj.target is a dynamically created input text field instance. Its instance name is returned and saved into a shared object as it should be when traced. After closing the movie the value of the instance, retrieved from the shared object is returned as undefined. The value of the input text is stored and returned correctly. I just wondered if anyone had come across this before.
            • 3. Re: problem with Shared Object
              mxc Level 1
              Well solved the problem by using String(eval(evt_obj.target))
              Still would like to know why it wont work when saved directly, must investigate when I have more time ;)
              • 4. Re: problem with Shared Object
                Jan-Paul K. Level 1
                if you know what the eval command should be used for, you should also know why it is working this way and not the other way.
                Take a look at the AS Dictionary part for the "eval" function and you will see that there is a big difference between
                eval(evt_obj.target)
                evt_obj.target

                So if "target" is only some textual information but not a reference to an object instance it is quite obvious that it didn't work without using eval. So you can either use eval or you simply store a real reference in the variable instead of onyl a textual id. BTW: The second approach without the eval would be the better way to go, since you are fully context indepent if you have a fully qualified reference to an object instance.

                Hope this helped a bit to understand what caused the problem initialy
                • 5. Re: problem with Shared Object
                  mxc Level 1
                  Thanks for your reply. I know what the eval function does and therefore did not use it to start with. The second approach you mention is the one I was using to start with and was returned as undefined from the shared object. So using eval was the only way out.
                  • 6. Re: problem with Shared Object
                    Jan-Paul K. Level 1
                    I think you didn't get my point. But well, as long as it works for you using eval, everything is ok and the problem is solved :-)
                    • 7. Re: problem with Shared Object
                      mxc Level 1
                      maybe it is a language misunderstanding ;) but many thanks for your interest

                      best regards
                      Michael