I am trying to trigger a function from inside my “column” MC via an eventListener from my “checkBoxes” MC. Is it even possible or should I look a different way?
my “column” MC code:
act_btn.addEventListener(MouseEvent.CLICK, actPoint);
function actPoint(m:MouseEvent){
cA.height = cA.height + 10;
var clickSound:pointPlus = new pointPlus ();
clickSound.play(0,1);
if(cA.height == 200){
act_btn.removeEventListener(MouseEvent.CLICK, actPoint);
}
}
and this is the code from my “checkBoxes” MC:
cbPlus_btn.addEventListener(MouseEvent.CLICK, actPoint);
As you can see, I added “actPoint” function to two different eventListeners…
…and of course, it`s not working 🙁
You can assign as many event listeners as you want to the same function. The key (and I think this may be your problem) is that the function you want to set as the listener has to be visible from the context in which you’re trying to do so.
I think your problem is that you’re not actually referencing the
actPointmethod within your columnMovieClipwhen you try to create the click listener on the check box (if you post any error messages you’re seeing in the console we may be able to confirm this).Assuming the check box is created in the same scope as the column
MovieClip, and assuming it has an instance name, you should be able to solve your issue by changing the code which adds the event listener on the check box to the following: