# Please have a look what's wrong w. this code

**URL:** <https://forum.kirupa.com/t/please-have-a-look-whats-wrong-w-this-code/244480>\
**Category:** flash\
**Created:** [November 18, 2007, 11:37pm UTC](https://forum.kirupa.com/t/please-have-a-look-whats-wrong-w-this-code/244480 "2007-11-18T23:37:13Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![tsf06](https://avatars.discourse-cdn.com/v4/letter/t/50afbb/32.png) [@tsf06](https://forum.kirupa.com/u/tsf06)\
**Post date:** [November 18, 2007, 11:37pm UTC](https://forum.kirupa.com/t/please-have-a-look-whats-wrong-w-this-code/244480/1 "2007-11-18T23:37:13Z")

</div>

Hi,

I found a bit of code for “magnetic effx” but this works only with Flash player 6 and earlier.  
Does anybody know how to make it work with FP 8.

Here is the code:

[COLOR=Navy]MovieClip.prototype.onEnterFrame = function()  
{  
if (this.\_name != “”)  
{  
if (!this.defaultX) this.defaultX = this.\_x;  
if (!this.defaultY) this.defaultY = this.\_y;  
magnet = 500;  
this.X0 = this.\_x;  
this.y0 = this.\_y;  
this.X1 = \_root.\_xmouse;  
this.Y1 = \_root.\_ymouse;  
this.distanceX = this.X1-this.X0  
this.distanceY = this.Y1-this.Y0  
this.distance = Math.sqrt((this.distanceX \* this.distanceX) + (this.distanceY \* this.distanceY))  
this.powerX = this.\_x - (this.distanceX / this.distance) \* magnet / this.distance;  
this.powerY = this.\_y - (this.distanceY / this.distance) \* magnet / this.distance;  
this.forceX = (this.forceX + (this.defaultX - this.X0) / 2) / 1.66  
this.forceY = (this.forceY + (this.defaultY - this.Y0) / 2) / 1.66  
this.\_x = this.powerX + this.forceX;  
this.\_y = this.powerY + this.forceY;  
}  
}

[COLOR=Black]Thanks for any advice![/COLOR]  
[/COLOR]
