PDA

View Full Version : this not returning correct value



Mythic Fr0st
June 3rd, 2007, 08:13 AM
function func_mainScrImg(e:Event)
{
for (i = 0; i<p.n; i++)
{
if (this == p.movie[i])
{
p.main.scr = new stage["img"+i]
}
}
}

if I trace (this.name) its root1

if I trace my movieclips (p.movie[i]) its instance 12-22)

this is the event listener I added to it


p.movie[i].addEventListener(MouseEvent.MOUSE_DOWN, func_mainScrImg)

now, it seems fine to me, but doesn't work? it should check properly

any idea's what im doin wrong?)

senocular
June 3rd, 2007, 02:09 PM
I dont know what you're checking but your traces are correct. The this variable will always be your main timeline (since that is where the function is defined) and p.movie[i] will be whatever you have in movie. Since they are named instance 12-22, they are not going to be your main timeline.