# For Loop & If/then statement

**URL:** <https://forum.kirupa.com/t/for-loop-if-then-statement/268628>\
**Category:** flash\
**Created:** [August 16, 2008, 4:59am UTC](https://forum.kirupa.com/t/for-loop-if-then-statement/268628 "2008-08-16T04:59:03Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Soig](https://avatars.discourse-cdn.com/v4/letter/s/eada6e/32.png) [@Soig](https://forum.kirupa.com/u/Soig)\
**Post date:** [August 16, 2008, 4:59am UTC](https://forum.kirupa.com/t/for-loop-if-then-statement/268628/1 "2008-08-16T04:59:03Z")

</div>

I have a For Loop that runs through 12 possible buttons. It checks to see if each one is supposed to be loaded and if not, it animates them to fade out. The for loop works fine, but the Outupt window displays the following.

> 

sect1  
sect1  
sect1  
sect1  
sect1  
sect1  
sect1  
sect1  
sect1  
sect1  
sect1  
sect1  
[type Function]

Its as if the IF statement is written incorrectly and AS 2.0 can’t find the function. Does anyone know why this happens or how I can fix it?

```auto
function clearButton() {
for (i = 0; i < 12; i++) {
    trace( _global.currentlyLoaded);
    if(_global.currentlyLoaded != ["sect"+i] && _root.mcBody["buttonCell"+i]._currentframe == 10) {_root.mcBody["buttonCell"+i].gotoAndPlay(11); }
        }
}

```
