单例模式访问舞台存在的对象
代码
private static var instance:View;
public static function getInstance():View {
if (instance != null) {
return instance;
} else {
instance = new View();
}
return instance;
}
public static function getInstance():View {
if (instance != null) {
return instance;
} else {
instance = new View();
}
return instance;
}
在实例化的时候,一定要在构造函数里面加上instance=this;
否则,对象访问空。


浙公网安备 33010602011771号