Skip to content

Instantly share code, notes, and snippets.

@448jp
Created January 25, 2012 17:33
Show Gist options
  • Save 448jp/1677482 to your computer and use it in GitHub Desktop.
Save 448jp/1677482 to your computer and use it in GitHub Desktop.
シングルトンパターン
package jp.ceroan {
import flash.errors.*;
/**
* Singleton
* @author OKI Yoshiya (ceroan)
*/
public class Singleton {
private static var _instance:Singleton = new Singleton();
private static var _uid:String;
public function Singleton() {
if (_instance) throw new IllegalOperationError("Singletonクラスはインスタンスを生成できません。");
}
/**
* Singletonクラスにアクセスするためのインスタンスを取得します。
* @return Singletonインスタンスを返します。
*/
public static function get instance():Singleton {
return _instance;
}
public function get uid():String { return _uid; }
public function set uid(value:String):void {
_uid = value;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment