Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Click and drag image sequence back and fourth, stop at first frame and last frame

Community Beginner ,
Apr 30, 2018 Apr 30, 2018

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);

}

}

TOPICS
ActionScript
300
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Apr 30, 2018 Apr 30, 2018

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

Translate
Community Expert ,
Apr 30, 2018 Apr 30, 2018

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Apr 30, 2018 Apr 30, 2018
LATEST

Thanks for the quick response JC.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines