# Proper rotation

**URL:** <https://forum.kirupa.com/t/proper-rotation/299064>\
**Category:** flash\
**Created:** [October 29, 2009, 8:19am UTC](https://forum.kirupa.com/t/proper-rotation/299064 "2009-10-29T08:19:01Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![BatteauProducts](https://avatars.discourse-cdn.com/v4/letter/b/eb8c5e/32.png) [@BatteauProducts](https://forum.kirupa.com/u/BatteauProducts)\
**Post date:** [October 29, 2009, 8:19am UTC](https://forum.kirupa.com/t/proper-rotation/299064/1 "2009-10-29T08:19:01Z")

</div>

Good morning people

Im going to try and explain what I’m trying to do, the short version (and in the best english, sorry for spelling mistakes etc.)

**Assignment:** Making a valve turn around by using the mouse, and thereby making a meter on another movieclip turn. The speed of the meter changes if you open the valve further.

**Problem:** The valve shouldnt be able to turn anymore after he’s completed a complete circle (360) or rather a bit less. Also the meter is starting te deplete (go left again) after i hit 180 degrees. Now I’ve traced the rotation of the valve its starts going in the negative after i reach 180. So I know the problem is to be found there just cant seem to solve it.

Thanks!

Here is my code:

```auto
//---------------------------------------------------ZUURSTOF_INITS----------------------------------------------//

var valveOpen:Boolean = false;

//---------------------------------------------------ZUURSTOF_FUNCTION-------------------------------------------//

valve_mc.onPress = function() {
    indrukken = true;
    valveOpen=true;
};

valve_mc.onRelease = valve_mc.onReleaseOutside = function() {
    indrukken = false;
};

_root.onEnterFrame = function() {
    if(valveOpen){
        meter_mc.arrow_mc._rotation += (valve_mc._rotation/50);
        output_txt.text = Math.floor(meter_mc.arrow_mc._rotation);
    }
    rad = Math.atan2((_root._ymouse-valve_mc._y), (_root._xmouse-valve_mc._x));
    graden = Math.round(rad*180/Math.PI);
    if (indrukken == true) {
        valve_mc._rotation = graden+180;
    }
}

```
