# \_rotation?

**URL:** <https://forum.kirupa.com/t/-rotation/33669>\
**Category:** flash\
**Created:** [October 22, 2003, 10:01am UTC](https://forum.kirupa.com/t/-rotation/33669 "2003-10-22T10:01:39Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nasier](https://avatars.discourse-cdn.com/v4/letter/n/839c29/32.png) [@Nasier](https://forum.kirupa.com/u/Nasier)\
**Post date:** [October 22, 2003, 10:01am UTC](https://forum.kirupa.com/t/-rotation/33669/1 "2003-10-22T10:01:39Z")

</div>

Ive this problem with rotating an object.  
What I want to do is rotate an object to  
108 degrees than rotate it back to 72 degrees.

So what I did was:  
[AS]  
onClipEvent (load) {

// set speed  
rotationSpeed = 2;

}

onClipEvent (enterFrame) {  
// start the motion  
\_rotation += rotationSpeed;

// rotate back when gone to far.  
if (\_rotationSpeed \>= 108) {  
rotationSpeed \*= -1;

// stop at 72 degrees  
if (\_rotation == 72) {  
\_rotationSpeed = 0;  
}  
}  
}  
[/AS]  
Atleast thats what I thought would work. but the stupid thingie rotates to 108 degrees, then rotates back the other way BUT DOESNT STOP AT 72 DGREES!!!

what am I doing wrong?

Nasier

---

<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:** [October 22, 2003, 10:25am UTC](https://forum.kirupa.com/t/-rotation/33669/2 "2003-10-22T10:25:48Z")

</div>

You should test on rotation in the first test.

And you need to move the second test ‘out’ a bit. Like this:

[AS]  
// rotate back when gone to far.  
if (\_rotation \>= 108) {  
rotationSpeed \*= -1;  
}

```
    // stop at 72 degrees
    if ((_rotation == 72) && (rotationSpeed &lt; 0)) {
            rotationSpeed = 0;
    }

```

[/AS]

In your code, the rotation has to be larger than or equal to 108 and at the same time be 72. It can’t be done.

Hope that helps.

---

<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:** [October 22, 2003, 8:06pm UTC](https://forum.kirupa.com/t/-rotation/33669/3 "2003-10-22T20:06:56Z")

</div>

```auto
onClipEvent (load) {
        
        // set speed
        rotationSpeed = 2;
        
}

onClipEvent (enterFrame) {
        // start the motion
        _rotation += rotationSpeed;
        
        // rotate back when gone to far.
        if (_rotation >= 108) {
                rotationSpeed *= -1;
        }         
        // stop at 72 degrees
         else if (_rotation == 72) {
                        _rotationSpeed = 0;
                }
        }

```

Shouldn’t it be this? Cuz I don’t see why he is checking to see if the rotationSpeed is less than 108 (which it is).

---

<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:** [October 22, 2003, 8:13pm UTC](https://forum.kirupa.com/t/-rotation/33669/4 "2003-10-22T20:13:39Z")

</div>

Steve, your code will stop the first time \_rotation reaches 72, so it’ll never get to 108.

I check on rotationSpeed to get the code to stop at 72, but only on the way back.

---

<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:** [October 22, 2003, 8:22pm UTC](https://forum.kirupa.com/t/-rotation/33669/5 "2003-10-22T20:22:43Z")

</div>

I’m no expert on \_rotation or anything but just out of curiosity - is it going back 72 degrees from 108? i.e. is it stopping at 36? Maybe you need to say:

// stop at 72 degrees  
else if (\_rotation == 36) {

?

Just a guess anyway . . .:whistle:
