Sunday, March 28, 2010

Help with a trace result

I have a button within a movieClip.

I have an event handler on the main timeline that traces this.name when the button is clicked.

I get 'root1' as the trace result.?Why is this?

I would like to trace the button name.?How can I do this?

Help with a trace result

''this'' refers to the timeline containing the code, so if that code is on the main timeline, which the name says it is, then that's what it will report.

In your event handler, try tracing the currentTarget of the event.... for example...

function btnHandler(evt:MouseEvent):void{

trace(evt.currentTarget.name);

}

Help with a trace result

That explains why when I originally had the trace command in an external class and associated the class with the button in the library it traced correctly-- because it was referring to the buttons' timeline.

correct?

After implementing your suggestion it worked...oddly enough.?

Thank you.

You're welcome.?I'd like to answer your wondering about the class, but I am class-challenged.?I normally avoid class-related postings, and for those I do I try to tread carefully.

no worries.

Thanks again for your help.

No comments:

Post a Comment