Código:
stage.addEventListener(Event.ENTER_FRAME, function() { poligonos(grupo.p1,-522,213.6); }); function poligonos(pol:MovieClip, homex:Number, homey:Number) { var x0 = pol.x ; var y0 = pol.y ; var x1 = parent.mouseX ; var y1 = parent.mouseY; var distancex = x1 - x0 ; var distancey = y1 - y0 ; var distance = Math.sqrt(distancex * distancex + distancey * distancey); var powerx = pol.x - distancex / distance * magnet / distance; var powery = pol.y - distancey / distance * magnet / distance; forcex = (forcex + (homex - x0) / 2) / magic; forcey = (forcey + (homey - y0) / 2) / magic; pol.x = powerx + forcex; pol.y = powery + forcey; }