Quelqu'un pourrais m'éclairer quant à ce code que j'ai du mal à décrypter ( je souhaite le comprendre pour pouvoir les réutiliser, ce code duplique un clip nommé "poly" sur la scene et au passage de la souris il repousse ces clips, imaginez une photo recouverte de pétales de rose et pour voir la photo il faut écarter tous les pétales en balayant l'image en quelque sorte ) :
function init()
{
for (i = 0; i <= nbPolyst; i++)
{
_parent.gotoAndPlay("init");
if (this["poly" + i]._x > this["poly" + i].X0 + 20 || this["poly" + i]._x < this["poly" + i].X0 - 20 || this["poly" + i]._y > this["poly" + i].Y0 + 20 || this["poly" + i]._y < this["poly" + i].Y0 - 20)
{
this["poly" + i].xDesti = this["poly" + i].X0 + random(20);
this["poly" + i].yDesti = this["poly" + i].Y0 + random(20);
this["poly" + i].deplacement(this["poly" + i].xDesti, this["poly" + i].yDesti);
} // end if
} // end of for
} // End of the function
distance = 100;
var nbPolyst = 600;
for (i = 0; i <= nbPolyst; i++)
{
duplicateMovieClip(poly, "poly" + i, this.getNextHighestDepth());
this["poly" + i].X0 = poly._x + (i - 10 * Math.floor(i / 10)) * 34;
this["poly" + i].Y0 = poly._y + 14 * Math.floor(i / 8);
this["poly" + i]._x = this["poly" + i].X0 + random(20);
this["poly" + i]._y = this["poly" + i].Y0 + random(20);
this["poly" + i]._rotation = random(360);
this["poly" + i].gotoAndStop(1 + random(9));
} // end of for
poly._visible = 0;
poly._visible = 0;
this.onMouseMove = function ()
{
if (distance < 900)
{
distance = distance + 1.200000;
} // end if
for (i = 0; i <= nbPolyst; i++)
{
this["distance" + i] = Math.sqrt(Math.pow(this["poly" + i]._x - _xmouse, 2) + Math.pow(this["poly" + i]._y - _ymouse, 2));
if (this["distance" + i] < distance)
{
this["poly" + i].yDesti = _ymouse + distance * ((this["poly" + i]._y - _ymouse) / this["distance" + i]);
this["poly" + i].xDesti = _xmouse + distance * ((this["poly" + i]._x - _xmouse) / this["distance" + i]);
this["poly" + i].deplacement(this["poly" + i].xDesti, this["poly" + i].yDesti);
} // end if
} // end of for
};
MovieClip.prototype.deplacement = function (xDep, yDep)
{
delete this.onEnterFrame;
this.onEnterFrame = function ()
{
this._x = this._x + (xDep - this._x) / 5;
this._y = this._y + (yDep - this._y) / 5;
if (this._x >= xDep - 1 && this._y <= xDep + 1 && this._y >= yDep - 1 && this._y <= yDep + 1)
{
delete this.onEnterFrame;
this._x = xDep;
this._y = yDep;
} // end if
};
};