Genera un temblor en la cantidad definida por el parámetro value. Si se usa sin parámetros detiene el temblor.
Actionscript:
MovieClip.prototype.shake = function(value) {
if (value) {
this.orgX = this._x;
this.orgY = this._y;
this.onEnterFrame = function() {
this._x = this.orgX+Math.random()*(value*2)-value;
this._y = this.orgY+Math.random()*(value*2)-value;
};
} else {
delete this.onEnterFrame;
this._x = this.orgX;
this._y = this.orgY;
}
};
//Uso 1
obj_mc.shake(5);//provoca un temblor de 5 pixeles
//Uso 2
obj_mc.shake();//detiene temblor
if (value) {
this.orgX = this._x;
this.orgY = this._y;
this.onEnterFrame = function() {
this._x = this.orgX+Math.random()*(value*2)-value;
this._y = this.orgY+Math.random()*(value*2)-value;
};
} else {
delete this.onEnterFrame;
this._x = this.orgX;
this._y = this.orgY;
}
};
//Uso 1
obj_mc.shake(5);//provoca un temblor de 5 pixeles
//Uso 2
obj_mc.shake();//detiene temblor
