Skip to main content
codynolen
Participant
May 12, 2020
Question

Interactive rotate object to follow movement of mouse

  • May 12, 2020
  • 1 reply
  • 1373 views

How can I create this rotation (following mouse movement) on an image, in Animate? http://jsfiddle.net/opherv/ddGHz/

    This topic has been closed for replies.

    1 reply

    JoãoCésar17023019
    Community Expert
    Community Expert
    May 12, 2020
    codynolen
    codynolenAuthor
    Participant
    May 12, 2020

    It was a start. I need to rotate an image file the same way.

    codynolen
    codynolenAuthor
    Participant
    May 22, 2020

    Hi again.

     

    Place the image inside of a Movie Clip instance.


    Here is the exact example of what I want, but it seems that I'm missing something.

     

    I finally got it 🙂 such a RELIEF 🙂

     

    stage.enableMouseOver(30);
    var _this = this;
    stage.on('stagemousemove', function(e){
    var radians = Math.atan2(e.localY - _this.movieClip_1.y, e.localX - _this.movieClip_1.x);
    var degrees = radians*(180 / Math.PI);
    _this.movieClip_1.rotation = degrees - 90;
    });