A Singleton is not necessarily the root of an application. That is, it's not
the client. The purpose of a Singleton is to ensure that one and only one
instance of that class is ever created. It's main feature is a public static
method called getInstance() that returns either that one instance. If it
doesn't exist yet, getInstance() will create one first.

Here is a link to the code samples that accompany Actionscript 3 Design
Patterns from Oreilly.
http://examples.oreilly.com/9780596528461/AS_30_DP_Code_Samples.zip
Look in chapter 3 for examples of Singletons. Notice the private class
embedded into the class which must be called for instantiation. This
prevents instances of the singleton from being created by other parts of the
app.

You can still write all of your code in frame 1 but in as3, it's virtually
the same thing as entering the name of a Document class in the main
properties panel.

On Mon, Dec 1, 2008 at 9:46 AM, Mendelsohn, Michael <
[EMAIL PROTECTED]> wrote:

> Hi list...
>
> Slowly but surely, I'm moving from AS2 to AS3.  In my AS2 projects, I
> usually create a singleton on frame 1 of the _root and everything takes
> off from there.
>
> What's the best practice of doing that in AS3, where I have to have a
> main class that seems to start everything.  I can't imagine how a
> singleton controlling all logic should extend a Sprite class.  Is it OK
> to still instance a singleton on the root in frame 1 even with a
> document class automatically instancing too?
>
> Thanks,
> - Michael M.
>
> _______________________________________________
> Flashcoders mailing list
> [email protected]
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>



-- 
--Joel Stransky
stranskydesign.com
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to