cheers mate On Wed, Jan 21, 2009 at 4:47 PM, Alan Shaw <[email protected]> wrote:
> I actually prefer your usage. The reason not to use it would be that > 'everybody' expects to use getInstance(). > > -A > > > On Wed, Jan 21, 2009 at 10:35 AM, allandt bik-elliott (thefieldcomic.com) > < > [email protected]> wrote: > > > Does anyone know of any reason not to use an accessor in my singleton > > instead of a function? > > > > so would this work okay (bearing in mind - as2) > > > > class com.publicis.hp.NavData > > { > > private static var _instance:Data; > > > > public var myVar:String; > > > > private function Data() > > { > > trace("This class is a singleton to hold data, please use > > Data.instance"); > > } > > > > public static function get instance():Data > > { > > if (!Data._instance) > > Data._instance = new Data(); > > > > return Data._instance; > > } > > } > > > > rather than using > > > > public static function getInstance() > > > > The reason i ask is that i would find it neater to use it > > > > ie: > > var myString = Data.instance.myVar; > > > > rather than > > > > var myString = Data.getInstance().myVar; > > > > thanks > > a > > _______________________________________________ > > Flashcoders mailing list > > [email protected] > > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders > > > _______________________________________________ > Flashcoders mailing list > [email protected] > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders > _______________________________________________ Flashcoders mailing list [email protected] http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

