Copy link to clipboard
Copied
I've imported an image sequence into flash, only 10 frames. I want to be able to scrub the sequence back and forth, but I want the mc to stop when I reach the first frame and stop when I reach the last frame. Below is code I used from a previous post, which works for 360s but again I want it to stop when the first and last frames are reached.
Any help is appreciated.
photos.stop();
//
var startX:Number;
var startFrame:Number;
var changeDistance:Number;
var travelDistance:Number;
photos.addEventListener(MouseEvent.MOUSE_DOWN,pressHandler);
function pressHandler(e:MouseEvent):void {
stage.addEventListener(MouseEvent.MOUSE_UP,releaseHandler);
startX = photos.mouseX;
startFrame = photos.currentFrame;
stage.addEventListener(MouseEvent.MOUSE_MOVE,moveHandler);
}
function releaseHandler(e:MouseEvent):void {
stage.removeEventListener(MouseEvent.MOUSE_UP,releaseHandler);
stage.removeEventListener(MouseEvent.MOUSE_MOVE,moveHandler);
}
function moveHandler(e:MouseEvent):void {
changeDistance = photos.mouseX - startX;
travelDistance = startFrame + changeDistance;
if (travelDistance > photos.totalFrames) {
photos.gotoAndStop(travelDistance % photos.totalFrames);
} else if (travelDistance < 0) {
photos.gotoAndStop(photos.totalFrames + (travelDistance % photos.totalFrames));
} else {
photos.gotoAndStop(travelDistance);
}
}
Hi.
Remove the branching from the moveHandler function.
Like this:
function moveHandler(e:MouseEvent):void
{
changeDistance = photos.mouseX - startX;
travelDistance = startFrame + changeDistance;
photos.gotoAndStop(travelDistance);
}
I hope it helps.
Regards,
JC
Copy link to clipboard
Copied
Hi.
Remove the branching from the moveHandler function.
Like this:
function moveHandler(e:MouseEvent):void
{
changeDistance = photos.mouseX - startX;
travelDistance = startFrame + changeDistance;
photos.gotoAndStop(travelDistance);
}
I hope it helps.
Regards,
JC
Copy link to clipboard
Copied
Thanks for the quick response JC.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now