Skip to main content
NJArtist
Participating Frequently
August 8, 2017
Answered

Issues with Mouseover and Mouseout

  • August 8, 2017
  • 3 replies
  • 5755 views

Hi All, I am trying to transition an old animation over from flash into html5. It would start out as a bar on the side and when hovered over, it would side across the screen and display its content Once the person moved off the content, it would slide back into place. it worked just fine in flash but doesn't translate well in html5. I have been able to set up the mouseover and mouseout functions, but it activates the mouseout gotoandplay function while still hovering over the content. Is there a way that i can have it only activate the animation once the cursor is fully off the content?

below is the code i am using for both fucntions

Mouseover

this.stop();

var frequency = 1;

stage.enableMouseOver(frequency);

this.movieClip_1.addEventListener("mouseover", fl_MouseOverHandlerToGoToAndPlayFromFrame.bind(this));

function fl_MouseOverHandlerToGoToAndPlayFromFrame()

{

this.gotoAndPlay(2);

}

Mouseout

this.stop();

var frequency = 1;

stage.enableMouseOver(frequency);

this.movieClip_1.addEventListener("mouseout", fl_MouseOutHandlerToGoToAndPlayFromFrame.bind(this));

function fl_MouseOutHandlerToGoToAndPlayFromFrame()

{

this.gotoAndPlay(8);

}

thanks for any help provided

    This topic has been closed for replies.
    Correct answer RandomlyFish

    Did you make sure to stop the animation when it's extended, using "this.stop();"?

    This code worked for me:

    // Frame 1:

    var main = this;

    var sidebar = main.movieClip_1;

    main.stop();

    stage.enableMouseOver();

    sidebar.addEventListener("mouseover", SidebarShow);

    sidebar.addEventListener("mouseout", SidebarHide);

    function SidebarShow () {

         main.gotoAndPlay(1);

    }

    function SidebarHide() {

         main.gotoAndPlay(8);

    }

    // Frame 8:

    this.stop();

    3 replies

    NJArtist
    NJArtistAuthor
    Participating Frequently
    August 9, 2017

    First off thanks for your responses. I really appreciate it. Sadly While the basic function of RandomlyFish's code worked, it still continues to repeat the animations while hovering over the moved bar. My hope was that it would move in with a mouse over and move out once the mouse cleared the clip. Instead it just keeps repeating while you are still over the clip. Basically the cursor has to remain COMPLETELY still for it not to repeat the sequence

    Legend
    August 9, 2017

    Uh... the button isn't actually part of the sidebar, is it? Or entangled with it in any way?

    NJArtist
    NJArtistAuthor
    Participating Frequently
    August 9, 2017

    they are basically one and the same, which is how i had it in flash and it worked just fine. The movie clip is essentially a slim bar with the title of that content, along with the actual content that is hidden off canvas. When you moused over the title, it would slide the entire bar out with its content and then retract when the mouse moved off the content.

    RandomlyFishCorrect answer
    Inspiring
    August 8, 2017

    Did you make sure to stop the animation when it's extended, using "this.stop();"?

    This code worked for me:

    // Frame 1:

    var main = this;

    var sidebar = main.movieClip_1;

    main.stop();

    stage.enableMouseOver();

    sidebar.addEventListener("mouseover", SidebarShow);

    sidebar.addEventListener("mouseout", SidebarHide);

    function SidebarShow () {

         main.gotoAndPlay(1);

    }

    function SidebarHide() {

         main.gotoAndPlay(8);

    }

    // Frame 8:

    this.stop();

    Legend
    August 8, 2017

    Why are you enabling mouseover on the stage twice? Once it's enabled, it's enabled. And you're setting it to a polling rate of ONE time per second. That can't be good.