Skip to main content
AlexPromTrad
Inspiring
May 18, 2020
Answered

On touch and on hover interaction

  • May 18, 2020
  • 2 replies
  • 2086 views

Hi all,

I am unable to find an answer to this question when I google it. I probably don't know what to search as I think that my needs are pretty basic.

 

I have an image that I would like to make interactive.

There is text that needs to trigger an animation on the image either on hover or on touch.

I would like to do this in html 5 so that I can use this image on a website.

I have created all my movie clips, but despite I try, any code that I use won't trigger the play movie clip.

Rather than hints I would like to know if you are aware of such tutorials because I cannot find them.

Thanks in advance 🙂

    This topic has been closed for replies.
    Correct answer Colin Holgate

    As you said touch and hover, are you using CreateJS to be used on mobile devices? Most tutorials from the past have been for mouse on desktop, and a mouse does have a hover state. Finger may not have those, so you work around that by relying on when the mouse has entered the object.

    The EaselJS mouse events article may give you a start:

    https://createjs.com/tutorials/Mouse%20Interaction/

    You can play with this demo and look at the code. Note how with a mouse the objects do have a rollover effect, but on touch screen they don't:

    https://createjs.com/tutorials/Mouse%20Interaction/

    2 replies

    Colin Holgate
    Colin HolgateCorrect answer
    Inspiring
    May 19, 2020

    As you said touch and hover, are you using CreateJS to be used on mobile devices? Most tutorials from the past have been for mouse on desktop, and a mouse does have a hover state. Finger may not have those, so you work around that by relying on when the mouse has entered the object.

    The EaselJS mouse events article may give you a start:

    https://createjs.com/tutorials/Mouse%20Interaction/

    You can play with this demo and look at the code. Note how with a mouse the objects do have a rollover effect, but on touch screen they don't:

    https://createjs.com/tutorials/Mouse%20Interaction/

    AlexPromTrad
    Inspiring
    May 19, 2020

    Thanks, I solved the problem

    kglad
    Community Expert
    Community Expert
    May 18, 2020

    create a movieclip out the text you want to trigger your movieclip to play and assign it an instance name (eg, text_c):

     

    this.text_mc.addEventListener("click",clickF.bind(this));

    function clickF(e){

    this.mc.play();  // mc is instance name of movieclip you want to play

    }

    AlexPromTrad
    Inspiring
    May 18, 2020

    Thanks, unfortunately I am on my first rodeo, this I am afraid is not enough. I'd really like to follow a tutorial 🙂

    kglad
    Community Expert
    Community Expert
    May 18, 2020

    google tutorials for what you want.