Stuck with random motion - Help please

Iam a newbie to forums and i have been trying out the random tutorial given by kirpua here
http://www.kirupa.com/developer/actionscript/random_motion.htm

however i tried to modify the code and add my own scripting a little bit but though i feel the logic behind the code is correct i dont know why the movie clip moves in a erratic manner

can anyone pls help me

This is the code

onClipEvent (load) {

//data you may want to change
width = 500;
height = 500;
speed = Math.random()*2;
//initial positions
this._x=Math.random()*width;
this._y=Math.random()*height;
x_new = Math.random()*width;
y_new = Math.random()*height;

}
onClipEvent (enterFrame){
if(this._x<x_new)this._x+=speed; // checking if current position is < than the final position then move the movie clip forward
if(this._x>x_new)this._x-=speed; // // checking if current position is > than the final position then move the movie clip backward
if(this._x=x_new)
{
x_new = Math.random()*width;// if they are both same then assign new end value
}
}

as the clip moves forward and when its pos becomes equal to the final pos i randmly change the value of the final movie clip position in that case that final position may be greater than or less than the this._x if its lesser it will follow the first loop else if its greater it will follow the second loop

the movie clip keeps bouncing across the screen and moves very fast

Can someone help me :h:

wrong forum :smiley: // Sorry I’m not help for your dilemma.

should be in the flash forums man. can a mod please move this?

done