惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Recorded Future
Recorded Future
Security Archives - TechRepublic
Security Archives - TechRepublic
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Jina AI
Jina AI
I
InfoQ
D
DataBreaches.Net
人人都是产品经理
人人都是产品经理
腾讯CDC
GbyAI
GbyAI
V
Visual Studio Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Microsoft Azure Blog
Microsoft Azure Blog
F
Fortinet All Blogs
博客园 - 聂微东
美团技术团队
The Register - Security
The Register - Security
Engineering at Meta
Engineering at Meta
Apple Machine Learning Research
Apple Machine Learning Research
雷峰网
雷峰网
S
Schneier on Security
量子位
A
About on SuperTechFans
H
Help Net Security
MongoDB | Blog
MongoDB | Blog
S
SegmentFault 最新的问题
Know Your Adversary
Know Your Adversary
Cisco Talos Blog
Cisco Talos Blog
Vercel News
Vercel News
Simon Willison's Weblog
Simon Willison's Weblog
PCI Perspectives
PCI Perspectives
B
Blog
K
Kaspersky official blog
V
Vulnerabilities – Threatpost
aimingoo的专栏
aimingoo的专栏
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
U
Unit 42
G
Google Developers Blog
L
LINUX DO - 最新话题
Forbes - Security
Forbes - Security
AWS News Blog
AWS News Blog
P
Palo Alto Networks Blog
Security Latest
Security Latest
爱范儿
爱范儿
Attack and Defense Labs
Attack and Defense Labs
IT之家
IT之家
L
LINUX DO - 热门话题
D
Docker
P
Proofpoint News Feed
Y
Y Combinator Blog
P
Proofpoint News Feed

博客园 - 听棠.NET

别对我撒谎,神奇的“微表情”,你来测测看! 中国人自己的DISC-易为DISC行为风格分析认证专家 如何做好突发公共卫生事件应急指挥与决策系统建设?(突发公卫应急系统建设) 教你如何定制刻录自己喜欢的汽车音乐CD(自定义无损音乐APE格式) 应该让人一眼就能区分球队? 从富士康十连跳看欧美、日韩、台资企业的不同 富士康的十连跳折射出现代人的心理危机 黄颖的“迪诺曼”——上海世博会上的苏州身影 flex 客户端缓存 module swf(转) Flash Builder 4 正式版破解注册方法(flex4) 联网创业六大经典理论:没VC时该想想杂货店[转] 李娜的成长,借助DISC行为模式理论从成功走向下一个成功 如何移值(恢复、还原)Mysql中的innoDB的数据库。 [Flex]如何使用registerClassAlias来解决module中使用RemoteObject - 听棠.NET - 博客园 Flex与.NET进行Remoting数据交换时注意的三个问题。 - 听棠.NET - 博客园 人生的45个功课 价值观(职业锚)与职业的选择 职业兴趣测评这么火! 大学毕业前的自我检查清单
创建ActionScript3的Singleton单例类模型
听棠.NET · 2009-10-12 · via 博客园 - 听棠.NET

Posted on 2009-10-12 21:29  听棠.NET  阅读(836)  评论()    收藏  举报

在Actionscript中,Constructor(构造函数)只能声明为public,这与C#的语法有所不同,这就导致无法把Constructor设为Private或Protected。
那我们只能借用另一种方式来禁止new实例化。
我们可以通过另一个限制级的参数对象来控制:
package AppConfig
{
 public class Connection
 {
  private var _connectionString:String="sss";
  private static var _instance:Connection;
  public function Connection(enforcer:SingletonEnforcer)
  {
  }
  public static function getInstance():Connection
  {
   if(_instance==null)
   {
    _instance=new Connection(new SingletonEnforcer());
   }
   return  _instance;  
  }
  public function get connectionString():String
  {
   return _connectionString;
  }
 }
 
}
class SingletonEnforcer {}