package Src
{
/**
* Written by Leezhm, 10th February, 2009
* Contact :
[email protected] *
* An example of singleton class
**/
public class CSingleton
{
// variable
private static var _instance = new CSingleton();
protected function CSingleton()
{
}
public static function getInstance():CSingleton
{
if (undefined != CSingleton._instance)
{
return CSingleton._instance;
}
else
{
throw Error("Could not create the instace!");
}
}
}
}
package Src
{
/**
* Written by Leezhm, 14th February, 2009
* Contact :
[email protected] *
* An example of singleton class
**/
public class CSingleton
{
// variable
private static var _instance = new CSingleton(new SingletonEnforcer());
public function CSingleton(enforcer:SingletonEnforcer)
{
}
public static function getInstance():CSingleton
{
if (undefined != CSingleton._instance)
{
return CSingleton._instance;
}
else
{
throw Error("Could not create the instace!");
}
}
}
}
class SingletonEnforcer {}