# For loop v setinterval?

**URL:** https://forum.kirupa.com/t/for-loop-v-setinterval/30138
**Category:** Uncategorized
**Created:** [September 4, 2003, 10:24am UTC](https://forum.kirupa.com/t/for-loop-v-setinterval/30138 "2003-09-04T10:24:37Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![j0se](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/j0se/32/44_2.png) [@j0se](https://forum.kirupa.com/u/j0se)
#### Post date: [September 4, 2003, 10:24am UTC](https://forum.kirupa.com/t/for-loop-v-setinterval/30138/1 "2003-09-04T10:24:37Z")

</div>

i’m trying to tween an mc from alpha 0 to 100 with code

for(x=1; x\<100; x++) {  
myClip\_mc.\_alpha =x;  
}

the above is way too fast - so i trieda nested loop

i = 1;  
for(x=1; x\<10000; x++) {  
// slow down i’s increment  
i = (x / 100);  
myClip\_mc.\_alpha =i;  
}

i’m not sure that’s making any difference - my maths is hit-and-miss

still, the clip seems to tween too fast

could i use setinterval here and/or could somebody give me a hint as to how to achieve my goal?

cheers  
=)

---

<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: [September 4, 2003, 11:06am UTC](https://forum.kirupa.com/t/for-loop-v-setinterval/30138/2 "2003-09-04T11:06:07Z")

</div>

Try this instead:

```auto

onClipEvent(load){
alphaAMT = 0; //this can be between 0 and 100
speed = 3; //this can be any positive integer but 1 to 5 is preferrable
}
onClipEvent(enterFrame){
this._alpha += (alphaAMT - this._alpha)/speed;
}

```

Cheers!

---

<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: [September 4, 2003, 1:16pm UTC](https://forum.kirupa.com/t/for-loop-v-setinterval/30138/3 "2003-09-04T13:16:08Z")

</div>

hi and cheers for your help!

that works fine now  
🙂
