# Jiggle!

**URL:** <https://forum.kirupa.com/t/jiggle/167785>\
**Category:** open source\
**Created:** [November 1, 2005, 12:17am UTC](https://forum.kirupa.com/t/jiggle/167785 "2005-11-01T00:17:10Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![icio](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/icio/32/484_2.png) [@icio](https://forum.kirupa.com/u/icio)\
**Post date:** [November 1, 2005, 12:17am UTC](https://forum.kirupa.com/t/jiggle/167785/1 "2005-11-01T00:17:10Z")

</div>

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.

```auto
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:
