Skip to main content
vladimird31054633
Participant
October 11, 2018
Answered

Mouse scroll start animation

  • October 11, 2018
  • 1 reply
  • 775 views

Hello I need very simple function but can`t find any info for it:

i need on mouse scroll down / up to start function where animations load - is that possible?

Thanks 

    This topic has been closed for replies.
    Correct answer JoãoCésar17023019

    You can try something like this:

    function onMouseWheel(e)

    {

        if (this.anim.currentFrame == 0)

              this.anim.play();

    }

    document.getElementById('canvas').addEventListener('mousewheel', onMouseWheel.bind(this));

    document.getElementById('canvas').addEventListener('DOMMouseScroll', onMouseWheel.bind(this));

    Regards,

    JC

    1 reply

    JoãoCésar17023019
    Community Expert
    Community Expert
    October 11, 2018

    Hi.

    AS3 or HTML5?

    And do you need the animation to keep playing while the mouse wheel is being rotated or do you need the animation to only play once?

    Regards,

    JC

    vladimird31054633
    Participant
    October 11, 2018

    Hello, HTML5 , I need just one to be started. Both scroll down and up

    JoãoCésar17023019
    Community Expert
    JoãoCésar17023019Community ExpertCorrect answer
    Community Expert
    October 11, 2018

    You can try something like this:

    function onMouseWheel(e)

    {

        if (this.anim.currentFrame == 0)

              this.anim.play();

    }

    document.getElementById('canvas').addEventListener('mousewheel', onMouseWheel.bind(this));

    document.getElementById('canvas').addEventListener('DOMMouseScroll', onMouseWheel.bind(this));

    Regards,

    JC