dai nome istanza al mc (es. mc)
codice:
//Prototype che muove un mc nella posizione x,y specificata
//e lo scala del valore endScale passato in argomento
MovieClip.prototype.sposta = function(endX, endY, endScale, speed) {
this.onEnterFrame = function() {
var offset = 0.5;
var rx = Math.abs(endX-this._x);
var ry = Math.abs(endY-this._y);
var rscale = Math.abs(endScale-this._xscale);
//Muovo il mc finche nn raggiunge la sua posizione finale e lo scalaggio desiderato
if ((!(rx<=offset)) && (!(ry<=offset)) && (!(rscale<=offset))) {
if ((!(rx<=offset)) && (!(ry<=offset))) {
var dx = rx/speed;
var dy = ry/speed;
(this._x<endX) ? this._x += dx : this._x -= dx;
(this._y<endY) ? this._y += dy : this._y -= dy;
}
if ((!(rscale<=offset))) {
(this._xscale<endScale) ? (this._xscale=this._yscale += rscale/speed) : (this._xscale=this._yscale -= rscale/speed);
}
} else {
//A spostamento completato e scalaggio desiderato elimino l'enterframe
delete this.onEnterFrame;
}
};
};
mc.onRollOver = function(){
this.sposta(endX, endY, endScale, speed)
};
mc.onRollOut = function(){
this.sposta(endX, endY, endScale, speed)
};
ovviamente a "endX, endY, endScale, speed" sostituisci con i valori che ti servono