Jiggle!

Here’s a little jiggling effect I created using the sin function.

Here’s the code, I’ve also attached the swf so that you can view it.

var jiggle:MovieClip; // movieclip on stage with instance name `jiggle`

jiggle.damp = 0.95;
jiggle.currJig = 0;
jiggle.swell = 120;
jiggle.pos = 0;
jiggle.spd = Math.PI/20;

jiggle.onRollOver = function() {
	if (this.currJig > 0) { return; }
	this.currJig = this.swell;
	this.pos = 0;
	_root.st = "< Jiggling!"; // textfield on the stage with `variable` set to "_root.st" displays this message.
	this.onEnterFrame = function() {
		this.updateJiggle();
	}
}
jiggle.updateJiggle = function() {
	this._xscale = this._yscale = 100+this.currJig*Math.sin(this.pos+=this.spd);
	this.currJig *= this.damp; if (this.currJig < 1) { this.currJig = 0;_root.st = "< Jiggle!"; delete this.onEnterFrame; }
}

Enjoy :thumb: