Quantcast
Channel: Adobe Community : All Content - Adobe Animate CC - General
Viewing all articles
Browse latest Browse all 13519

Controlling a movieclip with the position of the mouse

$
0
0

Good afternoon everyone,

 

I have been working on a small project at work, I'm trying to controll a movieclip that consists of 60 still images of an aircraft (120 frames total) that when played will show a 360 degree view of said aircraft. I can make it work with buttons, but I ultimately want to control the movieclip by moving the mouse. If anyone can help, that would be wonderful. Thanks in advance.

 

Here's the code:

 

import flash.events.MouseEvent;

 

 

ac.stop();

 

stage.addEventListener(MouseEvent.MOUSE_MOVE, mouseMove);

 

function mouseMove(event:MouseEvent):void
{
if(mouseX>800 && (mouseX<1600))
{
  ac.gotoAndStop(ac.currentFrame + 1);

  if(ac.currentFrame == 120)
  {
   ac.gotoAndStop(1);
  }
}
else
{
  ac.gotoAndStop(ac.currentFrame - 1);
 
  if(ac.currentFrame == 1)
  {
   ac.gotoAndStop(120);
  }
}
}

 

Using this code, the SWF acts ok with no errors. I can make the movieclip play in either direction, however, when moving the mouse back in the opposite direction the movieclip continues to play either forwards or backwards.

 

Thanks,

Tommy


Viewing all articles
Browse latest Browse all 13519


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>