Skip to main content
Participant
September 1, 2013
Answered

How can I code for a click and drag to progress forward/backward in timeline

  • September 1, 2013
  • 1 reply
  • 560 views

I'm working on a project, the goal is to have a .swf animation like this.

The functionality I'm looking for is:

1. I need my animation to make one full rotation and stop,

and then

2. I need to fix my AS3 so you have to CLICK/HOLD/DRAG to progress forward and backward through the timeline, but only when your holding the mouse button down.

Currently the code progresses the frame forward and backward in relation to the mouseX position.

Here is my current code:

import flash.events.MouseEvent;

var startPosition:Number=mouseX;

var delayTime=10;

gotoAndStop(1);

stage.addEventListener(MouseEvent.MOUSE_MOVE, onMouse);

function onMouse(e:MouseEvent):void{

   

    stage.removeEventListener(MouseEvent.MOUSE_MOVE,onMouse);

    var currentPosition:Number=mouseX;

    if(mouseX-startPosition<=0){

        nextFrame();

    }else{

        prevFrame();

    }

    setTimeout(setListener, delayTime);

}

function setListener(){

    startPosition=mouseX;

stage.addEventListener(MouseEvent.MOUSE_MOVE,onMouse);

}

any help would be appreciated,

Thanks.

This topic has been closed for replies.
Correct answer WHD2000

Found a thread much like this one that solved all my problems

Here the link to anyone who might be pulling their hair out trying to figure this out in the future

http://forums.adobe.com/thread/570903?tstart=0

Thanks Adobe Forums

1 reply

WHD2000Author
Participant
September 1, 2013

I have solved the problem with the image not making a full rotation at the begining by putting a stop(); at the top of the code, and placing all code in the final keyframe of my animation.

WHD2000AuthorCorrect answer
Participant
September 1, 2013

Found a thread much like this one that solved all my problems

Here the link to anyone who might be pulling their hair out trying to figure this out in the future

http://forums.adobe.com/thread/570903?tstart=0

Thanks Adobe Forums