# Rotating Movie Clip

**URL:** https://forum.kirupa.com/t/rotating-movie-clip/180623
**Category:** flash
**Created:** [March 2, 2006, 12:57am UTC](https://forum.kirupa.com/t/rotating-movie-clip/180623 "2006-03-02T00:57:34Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![z28power](https://avatars.discourse-cdn.com/v4/letter/z/ea666f/32.png) [@z28power](https://forum.kirupa.com/u/z28power)
#### Post date: [March 2, 2006, 12:57am UTC](https://forum.kirupa.com/t/rotating-movie-clip/180623/1 "2006-03-02T00:57:34Z")

</div>

Hello, I have an issue I’m trying to work out. I have a bird that is randomly flying around, but right now the bird only faces one way, wether it is going forward or backwards. I would like to get it to face the opposite direction, if it is flying in the opposite direction. (I hope this is clear). Below is the code that I have for the clip. I am new to flash 8, and I’ve gotten this code from one of the great tutorials here. Any help is greatly appreciated.

```auto
 
onClipEvent (load) { 
//data you may want to change 
width = 640; 
height = 480; 
speed = Math.round(Math.random()*2)+1; 
//initial positions 
x = this._x=Math.random()*width; 
y = this._y=Math.random()*height; 
x_new = Math.random()*width; 
y_new = Math.random()*height; 
} 
onClipEvent (enterFrame) { 
//x movement 
if (x_new>this._x) { 
sign_x = 1; 
} else { 
sign_x = -1;
_rotation = Math.atan2(this.yspeed, this.xspeed)*180/Math.PI;
} 
dx = Math.abs(x_new-this._x); 
if ((dx>speed) || (dx<-speed)) { 
this._x += sign_x*speed; 
} else { 
x_new = Math.random()*width; 
} 
//y movement 
if (y_new>this._y) { 
sign_y = 1; 
} else { 
sign_y = -1; 
} 
dy = Math.abs(y_new-this._y); 
if ((dy>speed) || (dy<-speed)) { 
this._y += sign_y*speed; 
} else { 
y_new = Math.random()*height; 
} 
} 

```

In case it matters, here is picture of the bird, perhaps it will help better explain what I want.

![](http://www.paradocksgrille.com/images/gull.jpg)
