Il codicde qui sotto crea una maschera a quadratini.
Ora anche quando l'animazione è finità senza fare altre operazioni la CPU rimane al 50-60% impallando i PC + lenti dove sbaglio?
come interrompere lo script una volta eseguito
codice:
foto._visible = 0;
MovieClip.prototype.move = function(targetRot, targetXsc, targetYsc, targetX, targetY) {
this._rotation = this._rotation+(targetRot-this._rotation)/4;
this._xscale = this._xscale+(targetXsc-this._xscale)/4;
this._yscale = this._yscale+(targetYsc-this._yscale)/4;
this._x = this._x+(targetX-this._x)/4;
this._y = this._y+(targetY-this._y)/4;
};
_root.attachMovie("IDmaschera", "maschera", 100);
_root.maschera.rettangolo._visible = 0;
_root.maschera._x = 550;
_root.maschera._y = 70;
j = 0;
for (i=1; i<=50; i++) {
duplicateMovieClip(_root.maschera.rettangolo, "rettangolo"+i, i);
//trace("rettangolo"+i);
_root.maschera["rettangolo"+i].targetX = (1/2*foto._width)-(1/2*maschera._width)-(j*maschera._width);
j++;
if (i/10 == Math.round(i/10)) {
j = 0;
}
_root.maschera["rettangolo"+i].targetY = (-1/2*foto._height)+(1/2*maschera._height)+(Math.floor((i-1)/10)*maschera._height);
_root.maschera["rettangolo"+i]._xscale = 1;
_root.maschera["rettangolo"+i]._yscale = 1;
_root.maschera["rettangolo"+i]._rotation = -170;
_root.maschera["rettangolo"+i].rit = 50*i;
t0 = getTimer();
_root.maschera["rettangolo"+i].onEnterFrame = function() {
if (getTimer()-t0>=this.rit) {
this.move(180, 100, 100, this.targetX, this.targetY);
_root.foto.setMask(maschera);
foto._visible = 1;
_root.maschera.rettangolo._xscale = 1;
_root.maschera.rettangolo._yscale = 1;
}
};
}