After all these days working with Flex Builder i never used the trace() method and to tell the truth i didn’t even look at this statement before, like what it does and what it really means.And when i found the usage of this statement i really felt bad for my ignorance,as my boss always says “kumar iam not happy with your ignorance”,hope this line doesn’t hurt anyonce’s feelings.
The trace() method is very usefull when debugging your App, it gives out the clear trace of the
statements in your App and keep track of values in the App while debugging.The output can be observed in the output window [ Console Window ],the values or statements we trace.
Example statements:
private var dtf:Date;
dtf=new Date();
trace(dtf.getTime());
trace(dtf.getHours());
trace(dtf.getMinutes());
trace(dtf.getSeconds());
trace(dtf.getHours()+”:”+dtf.getMinutes()+”:”+dtf.getSeconds());
Now debug the App and observe the results in the condole Window.
similarly another statement,
var i:int;
for(i=0;i<10;i++)
{
trace(i);
}
like wise we can use the trace() method, its a simple statement but veryusefull.![]()
console window is shown above.Enjoy the code.
Updated:
Read comment #2 below for more on the topic.


September 18, 2008 at 7:00 pm |
please tell me in detail.. this article is not in detail. i need help on this trace statement
<![CDATA[
public function init():void
{
var i:int;
for(i=0;i
it is showing nothing…
September 21, 2008 at 6:33 am |
To use the trace() method we got to switch to the debugging mode and debug your app and when the execution point reaches that point where you have added the trace() the result can be observed in the console window.the trace() method takes parameters what you want to view as a output, as shown in the above example.
regards,
kumar.
September 22, 2009 at 7:51 am |
tahnk u for ur articel…but you must have mentioned in the blog that this trace() will work only in debug mode but not in comments, because most of ur reader view only the blog content not the comments. any ways i got cleared my doubt. thanks for that.
September 25, 2009 at 5:35 am |
Hi Gowri Sankar,
Thanks for pointing out that, and i will update the post.
regards,
kumar.
October 10, 2009 at 12:34 am |
I usually don’t post on Blogs but ya forced me to, great info.. excellent! … I’ll add a backlink and bookmark your site.