2 Replies Latest reply on Oct 10, 2017 8:34 AM by keelym35886708

    Event listener on Stage is happening on top of Movieclip (and not on Stage)

    keelym35886708 Level 1

      I'm working on an HTML5 canvas document in Adobe Animate CC and writing the code in javascript. I have an event listener that seems to be firing off over my movieclips, but not over the stage - where I would like it to. I'm not a coder - so I apologize in advance.


      The project contains several movie clips named yoke, cyclic, and controlboard (this one is more of a background image).


      How I have it working now is when the cyclic movieclip is moved up and down with a pressmove function, the yoke movieclip will rotate. The code for that is: (I've got some stuff tabbed out since I'm reusing code from other projects)


      var shape = this.yoke;
      var stick = this.cyclic;
      var mouseMove = function () {
      var rads = Math.atan2(stage.mouseY - shape.y, stick.x - shape.x);
      var angle = rads * (180 / Math.PI) - offset;
      //var f = Math.floor(((shape.rotation + 360) % 360) * 0.086);
      shape.rotation = angle;
      console.log("angle:" + angle);
      var offset = 130; 
      this.cyclic.addEventListener("pressmove", fl_MouseClickHandler_2.bind(this));
      function fl_MouseClickHandler_2(evt){
      var p = this.globalToLocal(evt.stageX, evt.stageY+35);
      evt.currentTarget.y = Math.max(520, Math.min(570, p.y));
      /*this.cyclic.addEventListener("pressmove", mouseMove);
      var rads = math.atan2(stick.y - shape.y, stick.x - shape.x);
      offset = rads * (180 / Math.PI) - shape.rotation; */
      this.cyclic.addEventListener("mouseup", function(){
      alert ("angle:" + angle);


      What I would also like to happen - is when the user clicks (and holds the click) and slides the mouse along the X axis on the stage, that it will move through the frames of the yoke movieclip. What I wrote for that is:


      var i = this.yoke.currentFrame;
      this.stage.addEventListener("pressmove", fl_MouseClickHandler_3.bind(this));
      function fl_MouseClickHandler_3(){


      However - this action seems to be happening when I 'pressmove' my mouse along other movieclips (controlboard, cyclic), but not when I click and move the mouse on the stage. Not sure why this is - any help would be greatly appreciated! I'd also like to give a huge thanks to the forum users who have helped me get this far in my projects.