Hi,

Thank you very much for this.  This is cool.

Sammi

Michael Schmalle wrote:
>
> Hi,
>
> You don't neccessarily 'have' to use 'C' ;-)
>
> All you need to do is understand what a 'singleton' pattern means and 
> what bindable means.
>
> The principle of a model locator is simple. Create one object, create 
> a public API for the one instance and store your data in the one 
> instance while using data binding to dynamically update your public 
> API as it changes.
>
> Note:
>
> if you have a TextArea;
>
> <mx:TextArea text="{MyLocator.getInstance().welcomText}" />
>
> and somwhere else in your app you set the locators public property;
>
> MyLocator.getInstance ().welcomText = "Hello World";
>
> Then you text is instantly updated. The same applies to the text 
> EXCEPT, you need this in a change event from my testing if you are 
> tracking someone typing text and don't explictly set the 'text' 
> property of the TextArea.
>
> Here is the quasi class
>
> Class
> --------------------------------------------
> package my.package
> {
> [Bindable]
> public class MyLocator
> {
>     private static var instance:MyLocator = null;
>    
>     /**
>      * Returns the single instance.
>      */
>     public static function getInstance():MyLocator
>     {
>         if (!instance)
>             instance = new MyLocator();
>         return MyLocator;
>     }
>    
>     public function MyLocator()
>     {
>         super();
>         // you could throw an error here if instance is already crated
>         // you could initialize things here
>     }
>    
>     /**
>      * This is automatically bindable since the bindable tag is a
>      * above the class keyword.
>      */
>     public var welcomeText:String = "HelloWorld";
> }   
> }   
>
>
> Peace, Mike
>
> On 10/6/06, *Samúel Jónasson* <[EMAIL PROTECTED] 
> <mailto:[EMAIL PROTECTED]>> wrote:
>
>     Tom Chiverton wrote:
>
>>     On Friday 06 October 2006 10:05, Samúel Jónasson wrote:
>>       
>>>     What is the recommended way?  It is rather clumsy binding to
>>>     Application.application and I also think it makes sense to store all the
>>>     data in one place - not divide it in to multiple places.
>>>         
>>     Have you considered something like Cairngorn's ModelLocator singleton ?
>>
>>       
>     Hi,
>
>     Actually I haven't looked at all into Cairngorn.  I guess it
>     exists for a reason and that I should look into it.  I just wish
>     they had come up with a better name for it.  Not being able to
>     pronounce it's name has kept me away :)
>
>     Sammi
>
>
>
>
> -- 
> What goes up, does come down.
>  



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

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/flexcoders/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:[EMAIL PROTECTED] 
    mailto:[EMAIL PROTECTED]

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