# Another fading question

**URL:** <https://forum.kirupa.com/t/another-fading-question/178188>\
**Category:** flash\
**Created:** [February 8, 2006, 12:54pm UTC](https://forum.kirupa.com/t/another-fading-question/178188 "2006-02-08T12:54:46Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![coop](https://avatars.discourse-cdn.com/v4/letter/c/87869e/32.png) [@coop](https://forum.kirupa.com/u/coop)\
**Post date:** [February 8, 2006, 12:54pm UTC](https://forum.kirupa.com/t/another-fading-question/178188/1 "2006-02-08T12:54:46Z")

</div>

Hi again,  
I have another fading question, following form my last post.  
I have a series of images, that I want to fade between. So first image fades in stays for while then fades out and second image fades in, and so on.  
I wanted to use script and not timeline, so I have  
[AS]  
marine\_mc.\_alpha = 0;  
prop\_mc.\_alpha = 0;  
re\_mc.\_alpha = 0;  
var i = 0;  
var delay = 4000;  
var num = 10;  
img = [marine\_mc, prop\_mc, re\_mc];  
fadeIn(img\*, 10);  
function fadeIn(target, num) {  
target.onEnterFrame = function() {  
target.\_alpha += num;  
if (target.\_alpha\>=100) {  
target.\_alpha = 100;  
delete this.onEnterFrame;  
timeDelay = setInterval(out, delay);  
}  
};  
}  
function fadeOut(target, num) {  
target.onEnterFrame = function() {  
target.\_alpha -= num;  
if (target.\_alpha\<=0) {  
target.\_alpha = 0;  
this.onEnterFrame = null;  
clearInterval(timeDelay);  
if (i\>=img.length) {  
fadeIn(img[0], 10);  
} else {  
fadeIn(img[++i], 10);  
}  
}  
};  
}  
function out() {  
fadeOut(img\*, 10);  
}  
[/AS]

This workds fine, but I need it to loop back to the first image and start again, so it will be a looping ani.  
Any Help ?
