using the trace() method.

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.

console window is shown above.Enjoy the code.

Updated:

Read comment #2 below for more on the topic.

About these ads

6 Responses to using the trace() method.

  1. gs says:

    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…

  2. kumargandhi says:

    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.

  3. Gowri Sankar says:

    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.

  4. GeneTinsley says:

    I usually don’t post on Blogs but ya forced me to, great info.. excellent! … I’ll add a backlink and bookmark your site.

  5. Harish says:

    I understand about it now. I am using flex logging. The log will be printed in the console or in a separate log file. What benefits does trace has over logging ?
    please explain.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: