自定义类的示例如何调用该类的属性和方法

      Flash 2005-1-14 17:13
var classname = "main";
//the name of class
var iproperty = "subproperty";
//the name of property
var imethod = "submethod";
//the name of method
main = function () {
};
//
main.subproperty = function() {
    var a = arguments;
    var len = a.length;
    for (i=0; i<len; i++) {
        trace(typeof a[i]+":"+a[i]);
    }
};
main.prototype.submethod = function() {
    var a = arguments;
    var len = a.length;
    for (i=0; i<len; i++) {
        trace(typeof a[i]+":"+a[i]);
    }
};
invokemet = function (classname, imethod) {
    arguments.splice(0, 2);
    var c = eval(classname);
    var c=new c;
    return c[imethod].apply(null, arguments);
};
invokepro = function (classname, iproperty) {
    arguments.splice(0, 2);
    return eval(classname)[iproperty].apply(null, arguments);
};
invokepro(classname, iproperty, "v", 12, false);
invokemet(classname, imethod, "me");
标签集:TAGS:
回复Comments() 点击Count()

回复Comments

{commentauthor}
{commentauthor}
{commenttime}
{commentnum}
{commentcontent}
作者:
{commentrecontent}