You could add a method newInstance() that sets the internal instance
variable to a new instance;

 

Tracy Spratt,

Lariat Services, development services available

  _____  

From: flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com] On
Behalf Of Wally Kolcz
Sent: Sunday, February 14, 2010 1:08 PM
To: flexcoders@yahoogroups.com
Subject: [SPAM] [flexcoders] Killing a Singleton

 

  

I want when the user logs out, the instance of the Singleton that 
supports their global information to get set to null. How can you delete 
a Singleton existence or set it to null?

package org.mywindow.model
{

[Bindable]
public final class UserDataModel {

private static var instance:UserDataModel;

public function UserDataModel(singletonEnforcer:MySingletonEnforcer) {
if (singletonEnforcer == null) {
throw new Error ("UserDataModel is a singleton class, use 
getInstance() instead");
}
}

public static function getInstance():UserDataModel {
if (instance == null)
instance = new UserDataModel(new MySingletonEnforcer());
return instance;
}
}
}

class MySingletonEnforcer {}

Thanks!



Reply via email to