# Rotating a crank

**URL:** https://forum.kirupa.com/t/rotating-a-crank/104217
**Category:** Uncategorized
**Created:** [March 13, 2004, 6:53pm UTC](https://forum.kirupa.com/t/rotating-a-crank/104217 "2004-03-13T18:53:55Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![hondo311](https://avatars.discourse-cdn.com/v4/letter/h/6a8cbe/32.png) [@hondo311](https://forum.kirupa.com/u/hondo311)
#### Post date: [March 13, 2004, 6:53pm UTC](https://forum.kirupa.com/t/rotating-a-crank/104217/1 "2004-03-13T18:53:55Z")

</div>

I have this nifty crank . . . see cheesy image.

1. I want to animate this crank so that a user can “grab” the handle w/ the cursor and rotate it lke a real crank around a central axis.

2. it’ll be used as a navigation tool (forward/back) to scroll images.

3. added bonus: the faster the crank is spun, the faster the images scroll?

thanks so much for your help!

hondo311

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [April 6, 2004, 5:35pm UTC](https://forum.kirupa.com/t/rotating-a-crank/104217/2 "2004-04-06T17:35:44Z")

</div>

ok, this is my second way of trying to scroll images:

rotating the crank scrolls the images based on angle of rotation.  
the problem is that when i let go of the mouse, the crank stops and “sticks” and doesn’t work any more.  
i want the images to change as the crank is cranked, and be able to keep cranking in both directions during and after.

## fla is attached. here is the code for the crank:

mc.btn.onPress = function(){  
scrolling = true;  
}  
mc.btn.onmouseUp = function(){  
scrolling = false;  
}  
onEnterFrame = function(){  
if(scrolling){  
var dx=mc.\_x-\_xmouse;  
var dy=mc.\_y-\_ymouse;  
var rad = Math.atan2(-dy,-dx);  
var angle = (rad\*180)/Math.PI;  
mc.\_rotation=angle;

if (angle\>85 && angle\<=90) {  
trace("angle = "+angle);  
\_root.changePhoto(1);  
} else if (angle\>175 && angle\<=180) {  
trace("angle = "+angle);  
\_root.changePhoto(-1);  
}  
}  
}

* * *

images are also attached to test if it works. put them in a folder named “animation” in the same directory as the fla file.
