Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

How to use evt.currentTarget properly

Participant ,
Oct 31, 2018 Oct 31, 2018

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.

474
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Nov 01, 2018 Nov 01, 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...

Translate
LEGEND ,
Nov 01, 2018 Nov 01, 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...

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Nov 01, 2018 Nov 01, 2018
LATEST

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines