1 Reply Latest reply on Jul 12, 2006 6:41 AM by Newsgroup_User

    Globally available instances

    jallred
      In a nutshell what I want to be able to do is call

      var someInstance:SomeClass = new SomeClass();

      and have someInstance be globally available. By globally available I mean I want the ability to call someInstance.someMethod() from within methods of other objects, from the timeline of movieclips loaded into the parent movieclip, from basically anywhere actionscript code can reside.
        • 1. Re: Globally available instances
          Level 7
          jallred,

          > In a nutshell what I want to be able to do is call
          > var someInstance:SomeClass = new SomeClass();

          Okay.

          > and have someInstance be globally available.

          As long as you path to an object, you can find it. If you instantiate
          your class in the main timeline, you may reference that instance with _root,
          for example (just be aware that the location _root references is dependent
          on what level you're in, whether or not your SWF has been loaded into
          another, etc.).

          > By globally available I mean I want the ability to call
          > someInstance.someMethod() from within methods of
          > other objects, from the timeline of movieclips loaded
          > into the parent movieclip, from basically anywhere
          > actionscript code can reside.

          It may help you to think of movie clip timelines not as timelines per
          se, but simply as objects -- like anything else. The timeline metaphor does
          change things a bit, admittedly, but it only a metaphor, after all.
          Everything in ActionScript *is* an object, so OOP principles apply. :)

          I hear what you're saying. You could instantiate your class as a
          property of the _global object -- that would do it.


          David
          stiller (at) quip (dot) net
          Dev essays: http://www.quip.net/blog/
          "Luck is the residue of good design."