On 12/2/05, Mark Winterhalder <[EMAIL PROTECTED]> wrote:
> On 12/2/05, Marc Hoffman <[EMAIL PROTECTED]> wrote:
> > Jay,
> >
> > If you got this to work, could you send me the code? I can't make it
> > work even when doing the obvious clean-up to the line breaks and
> > changing naming conventions to AS2 (e.g. "Boolean" rather than "boolean").
>
> you can give the one i just hacked together proper testing, if you
> like, and let me know if it works...

forgot to check for the tag to avoid unwanted recursion. it didn't
cause a problem in my initial test because i had limited the recursion
depth (the ttl argument). sorry for the noise.

var types:Object = { movieclip: 1, object: 2, array: 4 };
var objTrace:Function = function( obj:Object, name2:String,
mask:Number, ttl:Number, indent:String, traceID:String ) {
 if( !indent.length ) indent = "\t";
 if( !( traceID.length ) )  traceID = String( getTimer() );
 if( !ttl )  ttl = 0;
 if( !mask )  mask = -1;
 if( !( arguments.callee.$$tag == traceID ) ) {
   arguments.callee.$$tag = traceID;
   arguments.callee.idCntr = 0;
 }
 var type:String = typeof obj;
 var id:String;
 if( types[ type ] ) {
   if( obj.$$id.length )  id = obj.$$id;
   else {
     id = obj.$$id = String( arguments.callee.idCntr++ );
     _global.ASSetPropFlags( obj, "$$id", 1, 0 );
   }
 } else id = "";

 trace( id + indent + name2 + " : " + type + ( id.length ? "" : "
\tvalue: " + obj ) );
 if( !( types[ type ] & mask ) || ( obj.$$tag == traceID ) )  return;
 obj.$$tag = traceID;
 _global.ASSetPropFlags( obj, "$$tag", 1, 0 );
 indent += "\t";
 if( !( --ttl ) ) return;
 for( var i:String in obj )
   arguments.callee( obj[ i ], i, mask, ttl, indent, traceID );
};


usage:
(if it works at all)

objTrace( object, name, mask, ttl );
where:
object is the root object of the trace, e.g. _root,
name is the name of the first object, e.g. "_root"
mask defines which kind of objects to follow, you define it by adding
their respective bits as defined in the types object in the first
line. so, 1 would only follow movieclips, 5 would follow movieclips
and arrys, but not objects (1 + 4), 6 would follow objects and arrays
(2 + 4), and so on. omitting it (or passing 0) would follow all of
them. another way is to pass something like that: ( types[ "movieclip"
] | types[ "object" ] | types[ "array" ] ), with the ones you want to
include.
ttl is the time to live, e.g. the depth of the recursion. 0 is unlimited.
indent and traceID are best omitted initially.

so, to trace all, you would simply say:
objTrace( _root, "_root" );
to trace all clips, but not objects and arrays:
objTrace( _root, "_root", 1 );
to trace all clips and all objects, but only to the grandchildren of root:
objTrace( _root, "_root", 3, 3 );
and so on.

--
http://snafoo.org/
jabber: [EMAIL PROTECTED]
_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to