Copy link to clipboard
Copied
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
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...
Copy link to clipboard
Copied
:
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);
}
Copy link to clipboard
Copied
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...
Copy link to clipboard
Copied
you're welcome.
(p.s when using the adobe forums, please mark helpful/correct responses, if there are any.)
Find more inspiration, events, and resources on the new Adobe Community
Explore Now