Copy link to clipboard
Copied
Hello, I have finally managed to create my event listeners for both mouse hover and tap, and a mouse out.
I have 16 elements that I need to enable animations for.
Each element has its own movie clip and dedicated button and a corresponding instance.
If I add another element to the code, I don't get the desired result as only the first button enables the last element programmed.
I don't understand why because all the instance names are correct and the code also has all the instances replaced in the code.
Is there something that I don't know and I should know when having multiple event listeners?
So far I have copied and pasted the same code replacing the instance names (and adding all the animation in the involved movie clips, with relative stops.
Plase, find the code below.
Thanks in advance 🙂
//BELLY
this.bellyBT.addEventListener("click", MouseClickFunction.bind(this));
function MouseClickFunction() {
this.bellyMC.play();
}
var frequency = 3;
stage.enableMouseOver(frequency);
this.bellyBT.addEventListener("mouseover", MouseOverFunction.bind(this));
function MouseOverFunction() {
this.bellyMC.play();
}
this.bellyBT.addEventListener("mouseout", MouseOutFunction.bind(this));
function MouseOutFunction() {
this.bellyMC.gotoAndPlay(6);
}
You can edit your posts, you know.
I didn't ask about the names of your buttons and movieclips, I asked about the names of your event handler functions. What are you calling them instead of "MouseClickFunction", etc. over and over?
Copy link to clipboard
Copied
I assume you haven't done something silly like creating 16 sets of event handler functions with the exact same names.
Copy link to clipboard
Copied
No, every instance has its own name and I haven't created more functions, because when I create the second group of event listeners and I give them the correct names, it only affects the first... so basically, what I want to happen with the second button, happens with the first button on the second animation.
Copy link to clipboard
Copied
What I do is copy and paste the code above, replace the handlers... the rule is simple, somethingBT and somethingMC, and that happens... This is my first time trying to make a script with Animate, so I am not completely sure if there is a different approach.
Copy link to clipboard
Copied
in case this is important... all the event listeners are in the frame 1 of the 'script' layer.
Copy link to clipboard
Copied
You can edit your posts, you know.
I didn't ask about the names of your buttons and movieclips, I asked about the names of your event handler functions. What are you calling them instead of "MouseClickFunction", etc. over and over?
Copy link to clipboard
Copied
You saved me!! I was looking in the completely wrong direction!
Yes, the function names!!
Sorry, I just realized I could edit my post.
Many thanks!