all groups > flash actionscript > july 2006 >
You're in the

flash actionscript

group:

Globally available instances


Globally available instances jallred
7/11/2006 9:31:10 PM
flash actionscript:
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.
Re: Globally available instances David Stiller
7/12/2006 9:42:15 AM
jallred,

[quoted text, click to view]

Okay.

[quoted text, click to view]

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.).

[quoted text, click to view]

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."

AddThis Social Bookmark Button