# Smooth Movie Clip Rotation

**URL:** https://forum.kirupa.com/t/smooth-movie-clip-rotation/5528
**Category:** flash
**Created:** [September 13, 2002, 9:00pm UTC](https://forum.kirupa.com/t/smooth-movie-clip-rotation/5528 "2002-09-13T21:00:45Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Mr\_Twinkles](https://avatars.discourse-cdn.com/v4/letter/m/9fc29f/32.png) [@Mr\_Twinkles](https://forum.kirupa.com/u/Mr_Twinkles)
#### Post date: [September 13, 2002, 9:00pm UTC](https://forum.kirupa.com/t/smooth-movie-clip-rotation/5528/1 "2002-09-13T21:00:45Z")

</div>

is there any way to get a smooth rotation in AS? I would assume i would use this.\_rotation, but it doesn’t smoothly rotate the way i want it to…  
I’m trying to make a movie clip that randomly goes to a location while rotating. here’s what code i have now.

onClipEvent (load)  
{  
speed = .2;  
xLocation = 0;  
yLocation = 0;  
}  
onClipEvent (enterFrame)  
{  
if (Math.ceil(this.\_x) == xLocation && Math.ceil(this.\_y) == yLocation)  
{  
xLocation = random(390);  
yLocation = random(190);

```
}
this._x = (this._x + (xLocation - this._x) * speed);
this._y = (this._y + (yLocation - this._y) * speed);

```

}

Any Ideas?

---

<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: [September 13, 2002, 9:06pm UTC](https://forum.kirupa.com/t/smooth-movie-clip-rotation/5528/2 "2002-09-13T21:06:19Z")

</div>

Ok, i’ve put in a clip of code where it continuously rotates, but how do i get it so it slows rotation when it gets closer to the point it’s going to?  
i used this.\_rotation += random(20);

---

<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: [September 13, 2002, 9:44pm UTC](https://forum.kirupa.com/t/smooth-movie-clip-rotation/5528/3 "2002-09-13T21:44:41Z")

</div>

I guess i might as well turn this into a tutorial, or someone else can, cause i figured out how to do this now.  
This is the line of code to make it rotate, i put some extras in there to make it seem like it’s rolling…

this.\_rotation = (yLocation - this.\_y) - (xLocation - this.\_x);

So there we go, i’ve solved my own problem.

---

<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: [September 14, 2002, 2:40am UTC](https://forum.kirupa.com/t/smooth-movie-clip-rotation/5528/4 "2002-09-14T02:40:54Z")

</div>

Sorry no one replied to you in time. Glad you got it working though. Good job sir.

---

<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: [September 14, 2002, 9:57am UTC](https://forum.kirupa.com/t/smooth-movie-clip-rotation/5528/5 "2002-09-14T09:57:39Z")

</div>

hehe yeah good work…i was working on a menu thing once and it sorta stuffed up after clicking the button 3 or 4 times…  
[Rotate Thing](http://home.iprimus.com.au/berryfam/temp/rotate.swf)

i havn’t looked it in a while…but yeah i dont know what the problem is…  
i think that if i had a look it might work agian hehe 🙂

---

<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: [September 16, 2002, 9:39pm UTC](https://forum.kirupa.com/t/smooth-movie-clip-rotation/5528/6 "2002-09-16T21:39:12Z")

</div>

Guess i might as well post this so that y’all can see what it looks like…only 1k. Sorry about it being geocities, just had to set something up real quick.

[http://www.geocities.com/randommovement2002](http://www.geocities.com/randommovement2002)

By the way, here’s the code:

onClipEvent (load)  
{  
speed = .1;  
xLocation = 0;  
yLocation = 0;  
}  
onClipEvent (enterFrame)  
{  
if (Math.ceil(this.\_x) == xLocation && Math.ceil(this.\_y) == yLocation)  
{  
xLocation = random(390);  
yLocation = random(190);

```
}
this._x = (this._x + (xLocation - this._x) * speed);
this._y = (this._y + (yLocation - this._y) * speed);
this._rotation = ((yLocation - this._x) + (xLocation - this._y)/2);

```

}
