[FMX2004] Why does this script not work when published as Flash Player v7?

Hi there,

I was hoping someone could help me. I was given this piece of script by a friend. It’s placed on a movie clip instance and makes it bounce away from the mouse pointer in random directions and distances. It’s a great piece and works fine when you publish your flash movie as v6. But I’m wanting to use it in a movie that I have to publish as v7 with as2, and it doesn’t work at all when you do that. Anyone know why?

Here’s the code:

 
onClipEvent(load){
var x=_x;
var y=_y;
var n=function(){
c=10000;
b=Math.floor(Math.random()*100);
d=b*b;
a=Math.sqrt(c-d);
if(Math.random()*2>=1){
b=-b;
}
if(Math.random()*2>=1){
a=-a;
}
tx=x+b;
ty=y+a;
}
}
onClipEvent (enterFrame) {
xm=_parent._xmouse;
ym=_parent._ymouse;
if (this.hitTest(xm,ym,true)) {
if (done!=1) {
n();
done=1;
i=30;
}
}
i--;
if (i<=1) {
xdif=x-_x;
xspeed+=xdif/4;
xspeed*=.8;
_x+=xspeed;
ydif=y-_y;
yspeed+=ydif/4;
yspeed*=.8;
_y+=yspeed;
} else {
done=0;
xdif=tx-_x;
xspeed+=xdif/4;
xspeed*=.8;
_x+=xspeed;
ydif=ty-_y;
yspeed+=ydif/4;
yspeed*=.8;
_y+=yspeed;
}
}
 

Hoping someone knows,

BeeKay