PDA

View Full Version : [AS2] Trace not working



John Barbarossa
February 1st, 2009, 05:35 PM
Hello. I have a trace pointed at a button that is inside a movieclip. So far targeting the button seems to be working, and the hit states and rollover effects all seem to be fine.

However, for some reason the trace I have put on release doesn't seem to be working. I've attached the .fla, but heres a sample of the code, in case it's something obvious. If anyone could take a look at this, I'd be very grateful. Its had me stumped for two days now (n00b alert).

First the code for attaching the mc that contains the button.


var newBtn = attachMovie("MP_v2RocketComponent", "MP_v2RocketComponent", _root.getNextHighestDepth());
newBtn._x = 370;
newBtn._y = 515;
Then I try to target the button inside it


MP_v2RocketComponent.v2RocketSectionBtn.onRelease = function()
{
trace("clicked on MP_v2RocketComponent");
}
Like I say, the button seems to be working, but won't seem to trace.

Thanks for taking a look.

neilmmm
February 1st, 2009, 07:59 PM
use your var ... it makes all simpler


var newBtn = attachMovie("MP_v2RocketComponent", "MP_v2RocketComponent", _root.getNextHighestDepth());
newBtn._x = 370;
newBtn._y = 515;
newBtn.onRelease = function()
{
trace("clicked on MP_v2RocketComponent");
}

John Barbarossa
February 2nd, 2009, 07:32 PM
Quite right Neil. That did it in the end. :)

rrh
February 3rd, 2009, 11:41 AM
If it wasn't tracing, what made you think "the button seems to be working?"

And MP_v2RocketComponent.v2RocketSectionBtn would be equivalent to newBtn.v2RocketSectionBtn, while newBtn would be equivalent to just MP_v2RocketComponent. So is the source of your problem the "v2RocketSectionBtn" part? Throw in a

trace(MP_v2RocketComponent.v2RocketSectionBtn+' < ' +MP_v2RocketComponent) and see what comes back.