Seems you are missing the constructor that actually performs the singleton protection, Here is an example of one way to create a singleton class (there are others):
************=================================*********** package com.somefolder.vo { [Bindable] public class TestClass { private static var testMe: TestClass; public var user_bemsid:Number = 0; public var user_fname:String = ""; public var user_lname:String = ""; public var user_mname:String = ""; // singleton: constructor only allows one user public function TestClass() : void { if ( _user != null ) { throw new Error( "Only one TestClass instance can be instantiated" ); } } // singleton: always returns the one existing static instance to itself public static function getInstance() : TestClass { if ( _user == null ) { _user = new TestClass(); } return _user; } } } ************=================================******* This is an example of how you init the class, if you try to init it more then once it will throw an error: import com.somefolder.TestClass; [Bindable] public var testModel : TestClass = TestClass.getInstance(); I would recommend looking into Cairngorm as it utilizes many design patterns that fix many issues you will run into as a developer using Flex. --- In flexcoders@yahoogroups.com, "ecpmaz" <[EMAIL PROTECTED]> wrote: > > Thank you for your answer, but it leads to the same behavior.. > > In my implementation, the Singleton is created the first time > TestClass' constructor is called (subsequent calls replaces instance > by a new one) > > {Maz} > > > > > 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} > > >