タグ

ブックマーク / sato-shi.hatenadiary.org (1)

  • シングルトンの書き方 - Flex Coder

    ActionScript3.0では、privateなコンストラクタを書けない制約があり、Singletonパターンを実装したクラスが定義できませんでした。んで、解決策が出ています。他のクラスから参照できないブロッククラスを用いる方法です。 Singleton.as package { public class Singleton { public function Singleton(blocker:SingletonBlocker) { if (blocker == null) throw new Error("Public construction not allowed. Use getInstance()"); } public static function getInstance() : Singleton { return instance; } private static

    シングルトンの書き方 - Flex Coder
    tmftake
    tmftake 2009/11/27
    コンストラクタをprivateに出来なくて焦った。
  • 1