While I see what you try to do, and have made a test all this stuff and don't like what I'm getting (sorry).
In Matt's implementation the only way to instantiate (due to the enforcer class inner nature) is using null:
var _singleton:MySingleton = new MySingleton (null); // --- (as pointed by Geoffrey)
what seems a little weird...
In Geoffrey's version there's a hack with Instantiation.locked static var that seems very strange turning (on and off a flag), again from other people's coming to the Flash platform they look at all this stuff as the typical flash hacks form old days.
I don't know why are you so reactive to introduce private constructors that are very clear and precise to resolve this kind of things and don't need any trick.
Another question is what's about Abstract classes that are again very needed.
Please rethink this two things so we could get a very flexible languaje and bring more people form other backgrounds to our beloved platform without think that we have a platform full of hacks.
Again, thanks for listening
C.
My preferred singleton/pseudo-private-ctor pattern is to use a static function facade:package {public class Manager{public static function x(){if (inner == null) inner = new ManagerImpl();inner.x();}private static var inner:ManagerImpl = null;}}class ManagerImpl(){public function x() {..}}If the facade gets too porky, you can use interfaces; make a public IManager interface in its own file, and have a "public static function Manager.getManager():IManager" function. That way you can only get the "gateway" class, and file-external code can't create a ManagerImpl.-rg
From: [email protected] [mailto:[email protected]] On Behalf Of Johannes Nel
Sent: Friday, February 10, 2006 7:16 AM
To: [email protected]
Subject: Re: [flexcoders] AS3 class constructors can't be private? Abstract classes?so even if i create a private class that is only accecible in that package (and then on package level declare a accesor for it) the only way i can be certain that class will only be created once is by having nothing else in that package. this does not seem right.
On 2/10/06, Matt Chotin <[EMAIL PROTECTED]> wrote:You have to simulate private constructors by having the constructor take a class that is inaccessible to other classes (namely putting that class in the same file as the singleton outside of the package block). Unfortunately I believe the rule is that the constructor of the class has to have the same visibility as the class itself. So public classes need public constructors, internal classes get internal constructors, etc.
Matt
From: [email protected] [mailto:[email protected]] On Behalf Of Johannes Nel
Sent: Thursday, February 09, 2006 4:51 PM
To: [email protected]
Subject: Re: [flexcoders] AS3 class constructors can't be private? Abstract classes?
abstract classes i am not expecting, private constructers i certainly hope for
On 2/9/06, Carlos Rovira <[EMAIL PROTECTED] > wrote:
Hi,
I was trying to migrate some classes from AS2 to AS3 and notice that can't mark the class constructor as private. Is that correct or there's a workaround? if not have plans to implement private constructors.
and abstract classes?
Thanks in advance.
--
::| Carlos Rovira
::| http://www.carlosrovira.com
--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.comSPONSORED LINKS
YAHOO! GROUPS LINKS
- Visit your group " flexcoders" on the web.
- To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
- Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
--
j:pn
--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.comSPONSORED LINKS
Web site design development Computer software development Software design and development Macromedia flex Software development best practice
YAHOO! GROUPS LINKS
- Visit your group "flexcoders" on the web.
- To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
- Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service .
--
j:pn
--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com
SPONSORED LINKS
Web site design development Computer software development Software design and development Macromedia flex Software development best practice
YAHOO! GROUPS LINKS
- Visit your group "flexcoders" on the web.
- To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
- Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service .
--
::| Carlos Rovira
::| http://www.carlosrovira.com
--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com
| Web site design development | Computer software development | Software design and development |
| Macromedia flex | Software development best practice |
YAHOO! GROUPS LINKS
- Visit your group "flexcoders" on the web.
- To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
- Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.

