单例模式访问舞台存在的对象

代码
private static var instance:View;

public static 
function getInstance():View {

   
if (instance != null) {
        
return instance;
   } 
else {
        instance 
= new View();
   }

   
return instance;
}

 在实例化的时候,一定要在构造函数里面加上instance=this;
否则,对象访问空。

posted @ 2010-01-25 14:15  韦君  阅读(79)  评论(0)    收藏  举报