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 回應:

匿名 提到...

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.