单例模式

package sound
{
/**
* @author zoe
*
*/
public class SoundManager
{
private static var _instance:SoundManager;
public static function getInstance():SoundManager
{
if(!_instance)
{
_instance = new SoundManager(new SingletonInfo());
}
return _instance;
}

public function SoundManager(singleInfo:SingletonInfo)
{
if(!singleInfo)
{
throw new Error("SoundManager is Singleton");
}
}
}
}

class SingletonInfo{}

原文地址:https://www.cnblogs.com/kuailezoe/p/2650768.html