# Help with random animation

**URL:** <https://forum.kirupa.com/t/help-with-random-animation/226803>\
**Category:** Uncategorized\
**Created:** [May 24, 2007, 4:57am UTC](https://forum.kirupa.com/t/help-with-random-animation/226803 "2007-05-24T04:57:33Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![iLoveAS](https://avatars.discourse-cdn.com/v4/letter/i/eada6e/32.png) [@iLoveAS](https://forum.kirupa.com/u/iLoveAS)\
**Post date:** [May 24, 2007, 4:57am UTC](https://forum.kirupa.com/t/help-with-random-animation/226803/1 "2007-05-24T04:57:33Z")

</div>

Hey guys, I’m working on a animation for a charity and i need to make some birds fly around the stage randomly, and change \_xscale depending which direction they are moving.

I have an if() statement to check if the new destination point is smaller or bigger than the current \_x position of each bird. This works perfectly, but when i use the continueTo() method, that if() statement isnt being called.

could someone please help me and tell me what im doing wrong.

here is the code for the birds.

* * *

function flight(){  
for (var i=0; i\<birds; i++){  
var bird:MovieClip = attachMovie(“crane”,“crane”+i,i+1);  
bird.gotoAndStop(Math.ceil(Math.random()\*10));  
bird.\_x = Math.random()\*1200;  
bird.\_y = Math.random()\*400;

```
    var birdScale:Number = bird._xscale = bird._yscale = Math.random()*50+20;
    var destPointY:Number = Math.random()*500;
    var destPointX:Number = Math.random()*1200;
    
    if(destPointX &lt; bird._x){
        bird._xscale = -birdScale;
    }else{
        bird._xscale = birdScale}
        
    var tween1:Object = new Tween(bird,"_x",Regular.easeInOut,bird._x, destPointX, Math.random()*5+2, true);
    var tween2:Object = new Tween(bird,"_y",Regular.easeInOut,bird._y, destPointY, Math.random()*5+2, true);
    
    tween1.onMotionFinished = function() {            
        this.continueTo(destPointX,Math.random()*5+2);
    };
    tween2.onMotionFinished = function() {            
        this.continueTo(destPointY,Math.random()*5+2);
    };
    
}

```

}

* * *

Thanx in advance for any help.
