If you're a purist, here's a couple of solutions:
http://www.gskinner.com/blog/archives/2006/07/as3_singletons.html

----- Original Message ----- 
From: "jrjazzman23" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Friday, July 14, 2006 3:42 PM
Subject: [flexcoders] Re: ModelLocator - Cairngorm 2


thanks for the response.  I think it solves the problem, however the
pseudo-private constructor can only be enforced at runtime.


--- In [email protected], [EMAIL PROTECTED] wrote:
>
> What about something like this?
>
>
>
> [Bindable]
> public class ShopModelLocator implements ModelLocator
> {
> private static var modelLocator : ShopModelLocator;
>
> public static function getInstance() : ShopModelLocator
> {
> if ( modelLocator == null )
> modelLocator = new ShopModelLocator();
>
> return modelLocator;
> }
>
>             public function ShopModelLocator()
>             {
>                   if ( ShopModelLocator.modelLocator != null )
>                         throw new Error( "Only one
ShopModelLocatorinstance
> should be instantiated" );
>             }
>
> public var products : ICollectionView;
> }
>
>
>
> |---------+----------------------------->
> |         |                             |
> |         |  "jrjazzman23"              |
> |         |  <[EMAIL PROTECTED]>    |
> |         |  Sent by:                   |
> |         |  [email protected] |
> |         |  07/14/2006 02:27 PM        |
> |         |  Please respond to          |
> |         |  flexcoders                 |
> |         |                             |
> |---------+----------------------------->
>
>-----------------------------------------------------------------------------------------------------------------------------|
>   |
                                                            |
>   |      To: [email protected]
                                                            |
>   |      cc:
                                                            |
>   |      Subject:  [flexcoders] ModelLocator - Cairngorm 2
                                                            |
>
>-----------------------------------------------------------------------------------------------------------------------------|
>
>
>
>
> I can't get the reference implementation to compile (pasted below).
> Seems to be missing a constructor. How should this be solved keeping
> in mind that private constructors aren't supported?
>
> [Bindable]
> public class ShopModelLocator implements ModelLocator
> {
> private static var modelLocator : ShopModelLocator;
>
> public static function getInstance() : ShopModelLocator
> {
> if ( modelLocator == null )
> modelLocator = new ShopModelLocator();
>
> return modelLocator;
> }
>
> public var products : ICollectionView;
> }
>
>
>
>
>
>
>
>
>
---------------------------------------------------------------------------
> This e-mail message (including attachments, if any) is intended for
the use
> of the individual or entity to which it is addressed and may contain
> information that is privileged, proprietary , confidential and
exempt from
> disclosure.  If you are not the intended recipient, you are notified
that
> any dissemination, distribution or copying of this communication is
> strictly prohibited.  If you have received this communication in error,
> please notify the sender and erase this e-mail message immediately.
>
---------------------------------------------------------------------------
>






--
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








--
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/
 


Reply via email to