----- Original Message -----
From: "Mendelsohn, Michael" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>; "Flash Coders List"
<[email protected]>
Sent: Monday, December 01, 2008 2:46 PM
Subject: [Flashcoders] structuring singletons in AS3
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?
I would say using the document class is to be preferred, but if you're using
the timeline then stick with that.
A singleton is just that - a single instance of a class. It doesn't matter
where you refer to it from ,it's always the same instance. The singleton can
extend anything it likes. The only difference between a singleton and a
regular class is how it's instantiated - you don't use the constructor.
http://en.wikipedia.org/wiki/Singleton_pattern#Actionscript_3.0
Paul
Thanks,
- Michael M.
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders