Hey alex, I looked through the powerpoint and can't quite understand exactly what a potential solution is.
Obviously both modules are creating their own instance, even though GCManager._instance is set the first time... Grr!! --- In [email protected], "Alex Harui" <[EMAIL PROTECTED]> wrote: > > That's effectively the shared-class problem described in the modules > presentation on my blog. > > > > ________________________________ > > From: [email protected] [mailto:[EMAIL PROTECTED] On > Behalf Of tchredeemed > Sent: Thursday, May 29, 2008 8:07 AM > To: [email protected] > Subject: [flexcoders] SingletonEnforced classes with modules > > > > I have created a SingletonEnforced class to hold variables that might > change, but will be > correct no matter where I access them. > > public class GCManager { > > private static var _instance:GCManager; > > public var currentId:int; > > public function GCManager( se:SingeltonEnforcer):void { > return; > } > > public static function getInstance():GCManager { > if(!GCManager._instance){ > GCManager._instance = new GCManager(new SingeltonEnforcer()); > } > return GCManager._instance; > } > > } > > class SingeltonEnforcer { > public function SingeltonEnforcer():void { > return; > } > } > > If I am in a Module (call it Module A), and I set the variable currentId > to any number, then I > switch to a differnt module (call it Module B), and I try to get the > variable currentId, it > returns 0. However, if I switch back to Module A, it is still the number > I set it to, and if I > then go back to Module B, it is still 0. > > This would lead me to believe it is creating duplicates, or more then 1 > instance. > > Any ideas? Anyone had a problem similar to this? >

