Skip to main content
Participant
August 26, 2021
Question

Mouseover event specific to button area only

  • August 26, 2021
  • 1 reply
  • 712 views

👋 community,

 

I have an issue with a mouseover event and was hoping that someone clever on here could help. Here's what I'm trying to achieve.

There's a legal button on the banner that will open a legal tray on mouseover and reverse animation on mouse out.

Right now, the mouseover and mouseout event listener is active when the mouse hovers over an area directly to the left of the button and directly over the legal button. Is there a way to detect the mouseover and mouseout event only on the button area.

This is the code I'm using:

var root = this;
var disclaimer = this.btn_disclaimer;
var disclaimer_tray = this.legal_tray;
var disclaimer_bg = this.dimmer_mc;

stage.enableMouseOver(20);

disclaimer.addEventListener("mouseover", showDisclaimer.bind(this));
disclaimer.addEventListener("mouseout", hideDisclaimer.bind(this));
disclaimer.mouseChildren = false;

function showDisclaimer() {
disclaimer_tray.gotoAndPlay('startDisclaimer');
disclaimer_bg.gotoAndPlay('startDisclaimer');
}


function hideDisclaimer() {
disclaimer_tray.gotoAndPlay('hideDisclaimer');
disclaimer_bg.gotoAndPlay('hideDisclaimer');
}

Thanks for the help!

    This topic has been closed for replies.

    1 reply

    kglad
    Community Expert
    Community Expert
    August 27, 2021

    you have all sorts of potential issues that can't be determined from what you've stated.  eg,

     

    1. what's in the global code?  

    2. what's the code on frame 29?

    3. where are the this.stop()'s?

    4. the code you showed is for mouse events on btn_disclaimer.  where/what's that and how's it related to "a legal button"?

    tamcao-aeAuthor
    Participant
    August 27, 2021

    Hi @kglad 

    Here is a little more details.  Please see attached.  Thanks for your help.

    kglad
    Community Expert
    Community Expert
    August 27, 2021

    that is screwy.  you really show stop giving each object mulitple names.

     

    anyway, remove that global script and put on the main timeline.