I forgot to show you how you use it.  So anywhwere in the application
you can now say: ModelLocator.getInstance().someProperty...

It provides you global access throughout you application.

--- In [email protected], "JWOpitz" <[EMAIL PROTECTED]> wrote:
>
> I don't have any small examples I could post here but if you want to
> dive into using MVC on Flex, check out the Cairngorm framework.  It
> provides you some useful classes to extend and implement regarding the
> structuring of the varous MVC components.
> 
> ModelLocator is a simple singleton class with getter/setter properties
> and I like to extend eventDispatcher.  Some folks like to make it a
> bindable class, however I try to avoid that as it has some overhead
> involved.  It looks something like this:
> 
> package {
> 
> public class ModelLocator extends EventDispatcher
> {
> 
>    private static var _instance:ModelLocator;
> 
>    public static function getInstance ():ModelLocator
>    {
>       if (!_instance)
>          _instance = new ModelLocator();
>       
>       return _instance;
>    }
> 
>    function ModelLocator (){}; //have this be an internal function so
> you don't have a publicly exposed constructor.
> 
> }
> }
> 
> --- In [email protected], "cksachdev" <cksachdev@> wrote:
> >
> > Hello J,
> > I am new to Design Patterns and currently using ARPX so I know 4 -5
> > patterns. I am using Application Domain but found that it can't help
> > me in Shell/Module pattern so I opt for mx.modules package. As you
> > mentioned Model Locator, please I would like to have a sample if you
> > can give me. Although I looked at it. Its same like Spring Service in
> > java. Please give any sample for Model Locator so that I can get
> > Shell/Module pattern ....
> >
>


Reply via email to