Title: Message
I've been playing with this a bit and my big, big question is this:  How the heck can you create a singleton when the contructor evidently must be public in AS 3.0?

Jeff Battershall
Application Architect
Dow Jones Indexes
[EMAIL PROTECTED]
(609) 520-5637 (p)
(484) 477-9900 (c)

-----Original Message-----
From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of Benoit Hediard
Sent: Tuesday, October 25, 2005 9:48 AM
To: [email protected]
Subject: RE: [flexcoders] Implementing ModelLocator pattern in AS3/Flex2

I don't think that bindings works on singleton instance syntax.
 
TestLocator.as
---------------------
package {
 
 public class TestLocator {
  
  private static var testLocator:TestLocator;
  
  public var someProperty:String;
  
  public static function getInstance():TestLocator {
   if(testLocator == null)
    testLocator = new TestLocator();
 
   return testLocator;
    }
  
  public function TestLocator() {
   this.someProperty = "Some value";
  }
  
 }
}
 
Test.mxml
-----------------
<?xml version="1.0" ?>
<mx:Application xmlns:mx="http://www.macromedia.com/2005/mxml" xmlns="*">
 
<mx:Script>
 <![CDATA[
  import TestLocator;
  
  private function onChangeClick():Void {
   TestLocator.getInstance().someProperty = 'Some other value';
  }
 ]]>
</mx:Script>
 
<mx:Label text="{TestLocator.getInstance().someProperty}" />
 
<mx:Button label="Change value" click="onChangeClick()" />
 
</mx:Application>
 
Anyway, I'll wait for the release of Cairngorm for Flex2.0 to see how Steven and Allistair did this part of their framework.
 
Thanks.
 
Benoit Hediard


De : [email protected] [mailto:[EMAIL PROTECTED] De la part de Matt Chotin
Envoyé : lundi 24 octobre 2005 19:39
À : [email protected]
Objet : RE: [flexcoders] Implementing ModelLocator pattern in AS3/Flex2

I haven’t investigated this for real but you may need to turn ModelLocator into a singleton so that there’s an instance of an object to watch.  Because we’re doing code-gen and not prototype hacking it’s impossible to make a Class object an EventDispatcher.  The singleton approach would allow us to use the code-gen and then you’d simply bind to ModelLocator.getInstance().myModel instead of ModelLocator.myModel.

 

Matt

 


From: [email protected] [mailto:[email protected]] On Behalf Of Clint Modien
Sent: Friday, October 21, 2005 12:18 PM
To: [email protected]
Subject: Re: [flexcoders] Implementing ModelLocator pattern in AS3/Flex2

 

Make the objects in the Model Locator typed.... by importing the classes you need to ref.

On 10/21/05, Benoit Hediard <[EMAIL PROTECTED]> wrote:

Since it is not possible to create bindings to static properties, how do you implement the ModelLocator pattern in AS3?

 

Benoit Hediard

 

PS: by the way, any information on an alpha release of Cairngorm for Flex2.0?



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




Reply via email to