I don’t see how your Singleton ever gets initialized. 

Did you try this:

=======

public static function get instance():TestClass {
if(_instance == null){
_instance = new TestClass();
}
return _instance;
}

========

Jim

________________________________________
From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of ecpmaz
Sent: Monday, May 07, 2007 7:31 AM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Binding on a singleton

Hi, 

I have a class implemented as a Singleton that get's initialized at
any time (unknown...)

-------------
public class TestClass extends EventDispatcher {

private static var _instance:TestClass;
private static var currentIndex:int = 0;
[Bindable] public var value:int;

public function TestClass() {
super();
_instance = this;
_instance.value = currentIndex++;
dispatchEvent(new Event("instanceChanged"));
}

[Bindable(event="instanceChanged")]
public static function get instance():TestClass {
return _instance;
}

public override function toString):String {
return "TestClass" + value;
}
}
--------------

I want any class to be able to monitor TestClass' instance change...
How would I do that. I tried many things, all without results..
I would like to use it like that for instance :

--------------
<mx:Label text="{TestClass.instance.toString()}" />
<mx:Button click="new TestClass()" /> <!-- hoping to chg Label's text -->
--------------

How would you do that ?

{Maz}
 

Reply via email to