2010-10-22

[ActionScript] var_dump()

function var_dump(value){
    var objRecursion=function(value,ofLine){
        if(ofLine.length>5){return '';} /*最大深度*/
        switch(typeof(value)){
            case 'movieclip':
            case 'object':
                var i, outTemp=[];
                for (i in value) {
                    outTemp.push(
                        ofLine+i+" => "+objRecursion(value[i], ofLine+'\t')
                    );
                }
                outTemp.push("("+typeof(value)+")");
                outTemp.reverse();
                return outTemp.join('\n');
            default:
                return value;
        }
    };
    
    var output = objRecursion(value,'');
    trace(output);
    return output;
}

1 則留言:

  1. Sorry for my bad english. Thank you so much for your good post. Your post helped me in my college assignment, If you can provide me more details please email me.

    回覆刪除

你好!歡迎你在我的 Blog 上留下你寶貴的意見。