Skip to main content
eugener2418576
Inspiring
October 31, 2018
Answered

How to use evt.currentTarget properly

  • October 31, 2018
  • 1 reply
  • 522 views

Hi there,

I want to use evt.currentTarget but I can't quite get my head around it.

I have 5 movie clips. Each with a 'clicked' label inside of them which show the users once the user have clicked.

I could easily create 5 movie clips with 5 different instance names - but I want to do it a little better using evt.currentTarget.

Currently all 5 movie clips are called 'noBtn'.

Here's my code - Currently this code only works for the last 'noBtn' (it only works for one of them) - but it should work for all 5 (or so I thought).

this.noBtn.addEventListener('click', fl_MouseClickHandlerNo.bind(this));

function fl_mouseClickHandlerNo(evt){

     var item = evt.currentTarget;

     item.gotoAndStop('clicked');

}

If anyone could give me a little explanation as to why it doesn't work that would be great.

This topic has been closed for replies.
Correct answer ClayUUID

eugener2418576  wrote

Currently all 5 movie clips are called 'noBtn'.

No. Just... no. You can't refer to multiple symbols by the same name. The IDE allows the illusion of giving the same name to multiple symbols, but once published, only one of them will actually have that name. The rest will receive automatically generated names like "instance_1", "instance_2", etc...

1 reply

ClayUUIDCorrect answer
Legend
November 1, 2018

eugener2418576  wrote

Currently all 5 movie clips are called 'noBtn'.

No. Just... no. You can't refer to multiple symbols by the same name. The IDE allows the illusion of giving the same name to multiple symbols, but once published, only one of them will actually have that name. The rest will receive automatically generated names like "instance_1", "instance_2", etc...

eugener2418576
Inspiring
November 1, 2018

Thank you, that's what I needed to hear!