# Looping question

**URL:** <https://forum.kirupa.com/t/looping-question/94583>\
**Category:** Uncategorized\
**Created:** [November 14, 2003, 7:36am UTC](https://forum.kirupa.com/t/looping-question/94583 "2003-11-14T07:36:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![hga77](https://avatars.discourse-cdn.com/v4/letter/h/4bbf92/32.png) [@hga77](https://forum.kirupa.com/u/hga77)\
**Post date:** [November 14, 2003, 7:36am UTC](https://forum.kirupa.com/t/looping-question/94583/1 "2003-11-14T07:36:00Z")

</div>

what am I doing wrong???

currentThumb.onRollOver = currentThumb.onDragOver = function(){  
this.\_alpha = 40;

}  
currentThumb.onRollOut = currentThumb.onDragOut = function(){  
while (alpha \< 100){  
alpha+=1;  
this.\_alpha = alpha;  
}

}

what im trying to do:

onRollover the alpha changes to 30. onRollout the alpha changes to 100 in steps. ie. fading in

please help

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [November 14, 2003, 9:55am UTC](https://forum.kirupa.com/t/looping-question/94583/2 "2003-11-14T09:55:00Z")

</div>

Use an [font=courier new]onEnterFrame[/font] handler or [font=courier new]setInterval[/font] instead of the [font=courier new]while[/font] statement. 🙂

```auto
function fadein() {
	this._alpha = Math.min(100, ++this._alpha);
	if (this._alpha == 100) {
		delete this.onEnterFrame;
	}
}
currentThumb.onRollOver = function() {
	this._alpha = 30;
};
currentThumb.onRollOut = function() {
	this.onEnterFrame = fadein;
};
//
function fadein() {
	currentThumb._alpha = Math.min(100, ++currentThumb._alpha);
	if (currentThumb._alpha == 100) {
		clearInterval(intervalid);
	}
}
currentThumb.onRollOver = function() {
	this._alpha = 30;
};
currentThumb.onRollOut = function() {
	intervalid = setInterval(fadein, 1000/12);
};

```
