2 Replies Latest reply on Sep 20, 2007 10:39 AM by Nixy

    static Class

    Nixy Level 1
      May be simple question, but...
      I've create a static Class. I call it on the main timeline. If I create a second instance anywhere else in the same movie, those two instance refer to the same object. I ceate instance usign MyClass.getInstance();.

      Well What I try to understand is the scope of that kind of Class. ie If I load a new swf in my main movie, in that new swf, on the first frame, there is MyClass.getInstance();. But it does not seem to refer to the same object. It's like that new instance, because it is not on the same file, is now a new object???

      Does it mean that Static Class Scope is only valid to the same swf file?
      If I remove an swf, does it means that all instances of Static Class in a swf is also cleared of the memory at the same time. So when reloaded, all the instance are new???

      I thought that static Class was create once in the memory and staying there
      Tanx to helping me understand better!
        • 1. Re: static Class
          Level 7
          >>Well What I try to understand is the scope of that kind of Class. ie If I
          >>load
          a new swf in my main movie, in that new swf, on the first frame, there is
          MyClass.getInstance();. But it does not seem to refer to the same object.

          It refers to the same object if it's indeed static. I use a static class to
          keep data between various movies and it works as expected. How did you
          determine it doesn't refer to the same object?

          --
          Dave -
          Head Developer
          http://www.blurredistinction.com
          Adobe Community Expert
          http://www.adobe.com/communities/experts/


          • 2. Re: static Class
            Nixy Level 1
            Simple mistake from my own code sorry.
            I keep the same object as you said.

            What Happends if the first created instanced is in a loaded clip, then we remove that clip. After that I load a new one and create a new instance. Does the previous instance is still in memory???