单例模式

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{}

posted on 2012-08-22 14:13  橙小风  阅读(128)  评论(0编辑  收藏  举报