Title: Message
Spike,
 
Thanks!  Why should we have to do such a kludgy workaround, though?  Why can't we have a private constructor if Java does? Suppose that's a question for the Flash Player engineering team...
 
Jeff
-----Original Message-----
From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Spike
Sent: Wednesday, October 26, 2005 11:16 AM
To: flexcoders@yahoogroups.com
Subject: Re: [flexcoders] Implementing ModelLocator pattern in AS3/Flex2

Yeah, my bad,

I wrote that in the email editor and didn't test it, but hopefully it demonstrates the idea.

Spike

On 10/26/05, Battershall, Jeff <[EMAIL PROTECTED]> wrote:
Hmmmm....shouldn't the private var 'instance' also be static?
 
Jeff
-----Original Message-----
From: flexcoders@yahoogroups.com [mailto: flexcoders@yahoogroups.com] On Behalf Of Spike
Sent: Wednesday, October 26, 2005 10:50 AM
To: flexcoders@yahoogroups.com
Subject: Re: [flexcoders] Implementing ModelLocator pattern in AS3/Flex2

package {
  public class MySingleton {
 
    private var instance:MySingleton;

    public MySingleton(x:PrivateClass) {
      instance = this;
    }

    public static getInstance():MySingleton {
      if (instance == null) {
        instance = new MySingleton(new PrivateClass());
      }
      return instance;
    }
  }

  private class PrivateClass {
   
  }
}

Something like that.

Spike


On 10/26/05, Battershall, Jeff <[EMAIL PROTECTED] > wrote:
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: flexcoders@yahoogroups.com [mailto: flexcoders@yahoogroups.com] On Behalf Of Benoit Hediard
Sent: Tuesday, October 25, 2005 9:48 AM
To: flexcoders@yahoogroups.com
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 : flexcoders@yahoogroups.com [mailto: flexcoders@yahoogroups.com] De la part de Matt Chotin
Envoyé : lundi 24 octobre 2005 19:39
À : flexcoders@yahoogroups.com
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: flexcoders@yahoogroups.com [mailto:flexcoders@yahoogroups.com] On Behalf Of Clint Modien
Sent: Friday, October 21, 2005 12:18 PM
To: flexcoders@yahoogroups.com
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






--
--------------------------------------------
Stephen Milligan
Do you do the Badger?
http://www.yellowbadger.com

Do you cfeclipse? http://www.cfeclipse.org



--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com




SPONSORED LINKS
Web site design development Computer software development Software design and development
Macromedia flex Software development best practice


YAHOO! GROUPS LINKS






--
--------------------------------------------
Stephen Milligan
Do you do the Badger?
http://www.yellowbadger.com

Do you cfeclipse? http://www.cfeclipse.org



--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com




SPONSORED LINKS
Web site design development Computer software development Software design and development
Macromedia flex Software development best practice


YAHOO! GROUPS LINKS




Reply via email to