# Drag trough image sequence calc, other solution?

**URL:** https://forum.kirupa.com/t/drag-trough-image-sequence-calc-other-solution/307237
**Category:** flash
**Created:** [March 31, 2010, 7:52am UTC](https://forum.kirupa.com/t/drag-trough-image-sequence-calc-other-solution/307237 "2010-03-31T07:52:13Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![anon45720911](https://avatars.discourse-cdn.com/v4/letter/a/a8b319/32.png) [@anon45720911](https://forum.kirupa.com/u/anon45720911)
#### Post date: [March 31, 2010, 7:52am UTC](https://forum.kirupa.com/t/drag-trough-image-sequence-calc-other-solution/307237/1 "2010-03-31T07:52:13Z")

</div>

Currently I’m working on a AS3 project where people can view pre-rendered 360 degree image sequence of 3D scenes or models. However I’ve been trying to find a decent way to scroll trough an image sequence by: Click & Drag.

To give an impression what I mean, here a link to a WIP application:  
[http://www.makeit3d.nl/client/vicem46/3drotate/index.html](http://www.makeit3d.nl/client/vicem46/3drotate/index.html)

The rotation functions to swap the image sequence works perfectly. However the mouse drag function not. When you drag the mouse on a decent speed it’s doing the job fine. But when dragging on a low speed it hardly moves and feels really ugly.

The drag functionality works like:

- on click, add event mouse movement listener
- get current position where mouse has clicked
- calculate: current mouse pos - clicked to start drag from
- calculate if drag is to left or right direction, and rotate

Current code I created for this Click & Drag functionality is:

```auto

        /*------------------------------------------------
            StartDrag
            info: enable drag rotate modus
                - stop auto rotation
                - add mouse event listener, get mouse position
                - calc drag direction
                - rotate according to drag direction
        ------------------------------------------------*/
        public function StartDrag():void {
            vrStatus = "DRAG";
            if(vrDragStatus){
                vrContainer.addEventListener(MouseEvent.MOUSE_MOVE, getMousePos);
                var sum:int = vrCurrDragPoint.x - vrLastDragPoint.x;
                vrLastDragPoint = vrCurrDragPoint;
                if (Math.abs(sum) > 5) {
                    if (sum > 0) {
                        RotateCCW();
                    } else {
                        RotateCW();
                    }
                }
            }
        }
        /*------------------------------------------------
            StopDrag
            info: stop drag and reset last drag point
        ------------------------------------------------*/
        public function StopDrag():void {
            vrStatus = "NONE";
            vrLastDragPoint = new Point(0, 0);
        }
        /*------------------------------------------------
            getMousePos
            info: get mouse position as x/y point
        ------------------------------------------------*/
        private function getMousePos(evt:MouseEvent):void {
            vrCurrDragPoint = new Point(evt.target.mouseX, evt.target.mouseY);
            //trace(vrCurrDragPoint);
        }

```

I hope someone can help me with creating a decent drag image sequence solution. I’ve ran out of ideas at the moment, tryed a few and the above one was so far the best.

Thanks already. 🙂
