From 492bde538f38596c9e5845337b1906a93cb2a331 Mon Sep 17 00:00:00 2001 From: Ray Greenwell Date: Tue, 4 Apr 2006 17:35:10 +0000 Subject: [PATCH] Added a note about singleton classes. I'm just whinging, really. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@3997 542714f4-19e9-0310-aa3c-eee0fc999fb1 --- src/as/com/threerings/README.txt | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/as/com/threerings/README.txt b/src/as/com/threerings/README.txt index 8919e58f7..2bcd776d7 100644 --- a/src/as/com/threerings/README.txt +++ b/src/as/com/threerings/README.txt @@ -328,3 +328,22 @@ ActionScript - add code to verify the object's functions against describeType calls.. (would need to iterate on types because describeType only finds methods in the terminal interface. Only # of args can be checked) + +- Private constructors are not allowed, so the official line from Macromedia + on creating Singleton classes, I-shit-you-not, is to do this: + +package foo { + +public class Singleton +{ + public static const singleton :Singleton = new Singleton(new SecretClass()); + + public function Singleton (secret :SecretClass) + { + } +} +} // end: package + +public class SecretClass // inaccessible outside this file +{ +}