# Swaying objects

**URL:** https://forum.kirupa.com/t/swaying-objects/192840
**Category:** Uncategorized
**Created:** [July 1, 2006, 9:28pm UTC](https://forum.kirupa.com/t/swaying-objects/192840 "2006-07-01T21:28:18Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![logikal2](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/logikal2/32/1143_2.png) [@logikal2](https://forum.kirupa.com/u/logikal2)
#### Post date: [July 1, 2006, 9:28pm UTC](https://forum.kirupa.com/t/swaying-objects/192840/1 "2006-07-01T21:28:18Z")

</div>

Hey guys,

I’m creating this menu that is moveable using startDrag and stopDrag. When you’re dragging it, it also “simulates” real movement by swaying in the wind. However, it doesn’t look too great yet. **Can anyone help me out by making this effect more realistic?**

[COLOR=“Green”]NOTE: Drag the menu by click-holding the top left yellow thingee.[/COLOR]  
Check out the .SWF file below…

Here’s the code:  
[AS]  
//----- MENU ROTATION EFFECT  
rot = 0;  
diff = 0;  
oldx = menu.\_x;  
function rotate() {  
newx = menu.\_x;  
if (newx != oldx) {  
newx\>oldx ? rot += 3 : rot -= 3;  
} else {  
rot\>0 ? rot -= 3 : null;  
rot\<0 ? rot += 3 : null;  
}  
rot\>50 ? rot=50 : null;  
rot\<-50 ? rot=-50 : null;  
menu.\_rotation = rot;  
oldx = newx;  
}

menu.drag.onPress = function() {  
menu.startDrag();  
dr = setInterval(rotate, 15);  
};  
menu.drag.onRelease = function() {  
menu.stopDrag();  
clearInterval(dr);  
};  
[/AS]

Thanks in advance! :kommie:  
Matt
