how to put an event listener on a movie clip from the library -- HTML5
Hi,
I am trying to instantiate a movie clip from the library and then add a "click" event listener to it. So far, I can get the clip out of the library and position it on the stage, but when I try to add an event listener to it, I can't get it working. I tried calling another function using the library name of the clip as a parameter, but that didn't work. The alert message just says, [MovieClip (name=null)]. Here's my code; any help will be appreciated.
Zaffer
let starFrontLg = new lib.starFrontLg();
var pickedFlower_mc;
this.blue_btn.addEventListener("click", getStarFrontLg.bind(this));
function getStarFrontLg()
{
this.addChild(starFrontLg);
starFrontLg.x = 200;
starFrontLg.y = 200;
pickFlower(starFrontLg);
}
function pickFlower(pickedFlower_mc){
alert(pickedFlower_mc); //alert says [MovieClip (name=null)]
}
pickedFlower_mc.addEventListener("click", clickSomeFlower);
function clickSomeFlower(e)
{
currentClickedFlower = e.currentTarget;
alert(currentClickedFlower);
}
