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

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

Explorer ,
Aug 31, 2013 Aug 31, 2013

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.

TOPICS
ActionScript
520
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

Explorer , Aug 31, 2013 Aug 31, 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

Translate
Explorer ,
Aug 31, 2013 Aug 31, 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.

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
Explorer ,
Aug 31, 2013 Aug 31, 2013
LATEST

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

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