That works in C# because the default access specifier for class members in C# is private. It won't work in ActionScript 3.0 because the constructor is always public, whether or not you declare it as such.
Francis > -----Original Message----- > From: [email protected] [mailto:[EMAIL PROTECTED] On > Behalf Of crnet_flex > Sent: Friday, April 14, 2006 3:19 PM > To: [email protected] > Subject: [flexcoders] Re: Singleton not usable? > > > Hi > > Have anyone tried using a construction like the following? > > public class Singleton > { > public static const Instance:Singleton = new Singleton(); > > function Singleton() > { > } > > public function doSomething():void > { > } > } > > This is actually the recommandations of creating a singleton in c#, > and it seems that it fullfils the job here as well. > > I know that, if you use flexbuilder 2 beta, then you'll get a > warning if you leave out the scope of the constructor, but maybe > it's worth it. > > By the way, be aware that the singleton posted initially as an > example is not a recommended way of creating a singleton, i guess > it's not a problem in AS3, but lazy loaded singletons must have a > syncronized/looked load section when thread safety is an issue. > > BR Casper -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/flexcoders/ <*> To unsubscribe from this group, send an email to: [EMAIL PROTECTED] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/

