Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 10-26-2011, 08:02 PM   #1
colfaxrev
bit chez fr.digital house
 
colfaxrev's Avatar
 
Join Date: Mar 2006
Location: Los Angeles
Posts: 688
Default trace_r for flash like print_r for php

look below for updated
__________________
Music is life

Last edited by colfaxrev; 10-26-2011 at 10:48 PM. Reason: updated content and reposted as reply
colfaxrev is offline   Reply With Quote
Old 10-26-2011, 08:36 PM   #2
northmantif
dont Re Member
 
Join Date: May 2009
Location: Poland
Posts: 739
Default

really nice. Most of the time I struggle with displaylist containers though to retrieve objects, their positions in the displaylist of specific objects. Wouldn't be handy to incorporate this to your class?
Cheers
northmantif is offline   Reply With Quote
Old 10-26-2011, 08:38 PM   #3
colfaxrev
bit chez fr.digital house
 
colfaxrev's Avatar
 
Join Date: Mar 2006
Location: Los Angeles
Posts: 688
Default

do you mean to see the hierarchy of x/y positions? maybe I should not get rid o x,y,rotation,width,height,scaleX,scaleY with that static array
__________________
Music is life
colfaxrev is offline   Reply With Quote
Old 10-26-2011, 08:40 PM   #4
colfaxrev
bit chez fr.digital house
 
colfaxrev's Avatar
 
Join Date: Mar 2006
Location: Los Angeles
Posts: 688
Default

or maybe you mean something like trace_r.displayHierarchy(dObj)

which would go the opposite way? getting its x,y its parents, xy, its parents, xy etc?
__________________
Music is life
colfaxrev is offline   Reply With Quote
Old 10-26-2011, 08:43 PM   #5
northmantif
dont Re Member
 
Join Date: May 2009
Location: Poland
Posts: 739
Default

I mean about childs index and their type in the displaylist generally.
northmantif is offline   Reply With Quote
Old 10-26-2011, 08:58 PM   #6
colfaxrev
bit chez fr.digital house
 
colfaxrev's Avatar
 
Join Date: Mar 2006
Location: Los Angeles
Posts: 688
Default

ah okay, so like child 0 is a MovieClip, its x,y,rotation, width, height, etc, all its children with the same, child 1 is a TextField, child 2 is a CustomClass stuff like that? that actually could be quite useful
__________________
Music is life
colfaxrev is offline   Reply With Quote
Old 10-26-2011, 09:03 PM   #7
northmantif
dont Re Member
 
Join Date: May 2009
Location: Poland
Posts: 739
Default

yep exactly. I do it very often with for() loop and even I could pass it to some kind of class but I always forget about it. Don't forget to output its index, that's what I use the loop mostly for (if you like the idea to implement such functionality)

Last edited by northmantif; 10-26-2011 at 09:06 PM.
northmantif is offline   Reply With Quote
Old 10-26-2011, 09:07 PM   #8
colfaxrev
bit chez fr.digital house
 
colfaxrev's Avatar
 
Join Date: Mar 2006
Location: Los Angeles
Posts: 688
Default

I think I do like that functionality, adding now
__________________
Music is life
colfaxrev is offline   Reply With Quote
Old 10-26-2011, 10:55 PM   #9
colfaxrev
bit chez fr.digital house
 
colfaxrev's Avatar
 
Join Date: Mar 2006
Location: Los Angeles
Posts: 688
Default

[reposted, because i wanted an easy to find name for ppl that might actually use it]

i have posted this somewhere on these forums before, although its gone through revisions over a couple years and is a bit better than the old one.

I always felt like actionscript was lacking something like print_r from php, so I made a trace_r for actionscript

the .as file is attached in a zip file (post was getting too long)

download and unzip trace_r.zip, and put it in the ROOT of your source folder.

that may look daunting to some, but all you have to do is use it

use it like this

ActionScript Code:
var urlR:URLRequest = new URLRequest('http://yahoo.com'); trace_r.run(urlR);

run it and in your trace window you will see this

Code:
[object URLRequest]
(
	[url] => string[http://yahoo.com]
	[requestHeaders] =>
	(
		[length] => number[0]
	)
	[data] => object[null]
	[method] => string[GET]
	[contentType] => object[null]
	[digest] => object[null]
)

i also added a way to omit tracing certain properties. (ex: printing DisplayObjects will print root, stage, parent etc...)

to omit properties you pass an array of strings for the properties you want to ignore

like so

ActionScript Code:
var urlR:URLRequest = new URLRequest('http://yahoo.com'); trace_r.run(urlR, ['requestHeaders', 'digest', 'contentType']);

which will print out

Code:
[object URLRequest]
(
	[url] => string[http://yahoo.com]
	[data] => object[null]
	[method] => string[GET]
)
since a lot of ppl will want to trace display objects I put in a static constant array to avoid all the things you probably don't want to trace from a display object , try this

ActionScript Code:
var mc:MovieClip = new MovieClip(); mc.age = 14; trace_r.run(mc, trace_r.IGNORE_DISPLAY_PROPS_ARRAY);

which will print out

Code:
[object MovieClip] - (ignoring all display object properties)
(
	[age] => number[14]
)
it even puts a message that you used the ignore display object properties array

now try this

ActionScript Code:
var mc:MovieClip = new MovieClip(); mc.age = 14; trace_r.run(mc);

you will get a lot more than you probably want to look at

anyway spread it to anyone that would like to use it, if you have any questions feel free to ask me

enjoy!


PS - now added the following functionality

you can run this

ActionScript Code:
trace_r.displayHierarchy(this);

this is safe to run on your document class

and it outputs something like so

Code:
[object Tester](ignoring all display object properties tracing display list children!)
(
	[displayList]
	[
		child[0][instance4][object Sprite]
		(
			[displayList]
			[
				child[0][instance6][object Sprite]
				(
					[displayList]
					[
						child[0][instance7][object TextField]
						child[1][instance8][object TextField]
						child[2][instance9][object TextField]
						child[3][instance10][object TextField]
						child[4][instance11][object TextField]
						child[5][instance12][object TextField]
						child[6][instance13][object TextField]
						child[7][instance14][object TextField]
						child[8][instance15][object TextField]
						child[9][instance16][object TextField]
						child[10][instance17][object TextField]
						child[11][instance18][object TextField]
						child[12][instance19][object Video]
					]
				)
			]
		)
		child[1][instance5][object TextField]
	]
)
this is useful to see a textual representation of your layout

you can also call

ActionScript Code:
trace_r.displayHierarchyDetailed(this);

which will print out the same but with added: x,y,width, height, etc type of simple display object info, it still does leave out a lot of properties to not over trace the entire app

enjoy!
Attached Files
File Type: zip trace_r.zip (3.0 KB, 45 views)
__________________
Music is life
colfaxrev is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 05:47 AM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.