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

click events in Adobe Animate CC

Participant ,
May 18, 2016 May 18, 2016

Dear Friends,

Iam converting an elearning lessons from Flash AS3 to  Animate CC - JS. I have the following code for an activity like click each buttons and see corresponding popups.

import flash.events.MouseEvent;

for (var i:Number = 1; i<=5; i++)

{

this["btn" + i].addEventListener(MouseEvent.CLICK, btn_clicked);

}

function btn_clicked(event:MouseEvent)

{

trace(event.target.name.substr(3));

popup.gotoAndPlay("pg"+event.target.name.substr(3));

}

it should go to particular popup.

Kindly help me to convert this to java script code in animate CC.

Thanks in Advance,

Syed Abdul Rahim

TOPICS
ActionScript
10.3K
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

Participant , May 21, 2016 May 21, 2016

Thks Mr.kgla,

I did this in the following way:

this.stop();
var sel_but = "";
_this = this;
for (inc1 = 1; inc1 <= 7; inc1++) {
this["btn_" + inc1].name = "button" + inc1;
this["btn_" + inc1].addEventListener("click", fl_MouseClickHandler);
}

function fl_MouseClickHandler(event) {
sel_but = event.target.name.substr(6);
_this.popUp.gotoAndPlay('pg'+sel_but);
}

May be useful to others...

Translate
Community Expert ,
May 18, 2016 May 18, 2016

:

var tl=this

for (var i = 1; i<=5; i++)

{

this["btn" + i].addEventListener('click', btn_clicked);

this["btn"+i].name=i.toString();

}

function btn_clicked(event)

{

tl.popup.gotoAndPlay("pg"+event.currentTarget.name);

}

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 ,
May 21, 2016 May 21, 2016

Thks Mr.kgla,

I did this in the following way:

this.stop();
var sel_but = "";
_this = this;
for (inc1 = 1; inc1 <= 7; inc1++) {
this["btn_" + inc1].name = "button" + inc1;
this["btn_" + inc1].addEventListener("click", fl_MouseClickHandler);
}

function fl_MouseClickHandler(event) {
sel_but = event.target.name.substr(6);
_this.popUp.gotoAndPlay('pg'+sel_but);
}

May be useful to others...

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
Community Expert ,
May 22, 2016 May 22, 2016
LATEST

you're welcome.

(p.s when using the adobe forums, please mark helpful/correct responses, if there are any.)

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