(function()
{
/*################################命名空间开始###########################*/
/*============================全局变量定义区开始=========================*/
//此范围内定义的变量与外部同名变量不冲突
var versioninfo =
{
/*主版本号 . 子版本号 [ 修正版本号 [. 编译版本号 ]]*/
Version: { Major: "0", Minor: "1", Revision: "5", Build: "alpha" },
Author: "hawkwolf",
Email: "zhandx@163.com",
Date: "2009-12-16",
getVersion: function() { return versioninfo.Version.Major + "." + versioninfo.Version.Minor + "." + versioninfo.Version.Revision + "." + versioninfo.Build }
};
var spaceLength = 50; //图元间距长度
/*============================全局变量定义区结束=========================*/
if (window.CObject == null)
{
/*****************************CObject组件开始***************************/
window.CObject = function(id)
{
Init(); //这里先调用了私有方法Init
/*----------------------------属性定义区开始-------------------------*/
/*****************************私有属性定义区开始**************************/
var other = "CObject";
var owner = this;
/*****************************私有属性定义区结束**************************/
/*****************************公有属性定义区开始**************************/
this.name = "CObject";
this.ID = id;
/*****************************公有属性定义区结束**************************/
/*****************************静态属性定义区开始**************************/
CObject.Counter++; //静态计数器
/*****************************静态属性定义区结束**************************/
/*----------------------------属性定义区结束-------------------------*/
/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@私有方法定义区开始@@@@@@@@@@@@@@@@@@@@@@@@@*/
function Init()
{
alert("at here is Init Code!");
};
function privateMethod()
{
alert('Invoke private method! output private variable other is "' + other.toString() + '", public variable ID is "' + this.ID.toString() + '", global variable version is "' + versioninfo.getVersion().toString() + '"');
};
function privateMethod1(msg)
{
alert(msg);
};
/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@私有方法定义区结束@@@@@@@@@@@@@@@@@@@@@@@@@*/
/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@特权方法定义区开始@@@@@@@@@@@@@@@@@@@@@@@@@*/
this.privilegeMethod = function()//在最后面添加
{
alert('Invoke privilage method! output private variable other is "' + other.toString() + '", public variable ID is "' + this.ID.toString() + '", global variable version is "' + versioninfo.getVersion().toString() + '"');
privateMethod1("this is privilage method invoke private method!");
};
this.privilegeMethod1 = function()//在最后面添加
{
alert('Invoke privilage method1! output private variable other is "' + other.toString() + '", public variable ID is "' + this.ID.toString() + '", global variable version is "' + versioninfo.getVersion().toString() + '"');
privateMethod1("this is privilage method invoke private method!");
};
/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@特权方法定义区结束@@@@@@@@@@@@@@@@@@@@@@@@@*/
};
/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@公有方法定义区开始@@@@@@@@@@@@@@@@@@@@@@@@@*/
CObject.prototype = {
getVersion: function()
{
//此公有方法如果写在构造函数外,那么访问other将不会成功!这里成功是因为此方法和other作用于相同缘故。
alert('Invoke public method! output public variable ID is "' + this.ID.toString() + '", global variable version is "' + versioninfo.getVersion().toString() + '"');
},
toString: function()
{
alert('"CObject"');
},
getType: function()
{
alert('"CObject"');
},
getOhter: function()//这里访问other会失败,不在作用域内的缘故
{
alert('Invoke public method! output private variable other is "' + other.toString() + '", public variable ID is "' + this.ID.toString() + '", global variable version is "' + versioninfo.getVersion().toString() + '"');
}
};
/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@公有方法定义区结束@@@@@@@@@@@@@@@@@@@@@@@@@*/
/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@静态方法定义区开始@@@@@@@@@@@@@@@@@@@@@@@@@*/
CObject.getCounter = function()
{
return CObject.Counter;
};
/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@静态方法定义区结束@@@@@@@@@@@@@@@@@@@@@@@@@*/
/*****************************CObject组件结束***************************/
}
/*################################命名空间结束###########################*/
})();