# How do i call a function in a loop in AS2?

**URL:** https://forum.kirupa.com/t/how-do-i-call-a-function-in-a-loop-in-as2/293561
**Category:** Uncategorized
**Created:** [July 30, 2009, 7:06pm UTC](https://forum.kirupa.com/t/how-do-i-call-a-function-in-a-loop-in-as2/293561 "2009-07-30T19:06:25Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![kibbik](https://avatars.discourse-cdn.com/v4/letter/k/b5a626/32.png) [@kibbik](https://forum.kirupa.com/u/kibbik)
#### Post date: [July 30, 2009, 7:06pm UTC](https://forum.kirupa.com/t/how-do-i-call-a-function-in-a-loop-in-as2/293561/1 "2009-07-30T19:06:25Z")

</div>

I have a function:  
[AS]function createWord(\_mc:MovieClip, textInside:String) {  
…  
}[/AS]  
This function creates a word inside of a movieclip. The words that it makes are specified in a text document in an array, and I don’t know how many there will be. Then I have a do while loop that creates movie clips for these words to go into:  
[AS]do {  
\_root.createEmptyMovieClip(“mc”+i+"\_mc",i);  
} for (word\*=word[i++]);[/AS]  
The only thing is, now I have to call the createWord() function for each of these created movieclips. Right now my code looks like this:  
[AS]createWord(mc1\_mc,word[1]);  
createWord(mc2\_mc,word[2]);  
createWord(mc3\_mc,word[3]);  
createWord(mc4\_mc,word[4]);  
createWord(mc5\_mc,word[5]);  
…  
createWord(mc25\_mc,word[25]);[/AS]  
Is there a way to call these functions in a loop?  
I’ve already tried this, but it didn’t work:  
[AS]do {  
\_root.createEmptyMovieClip(“mc”+i+"\_mc",i);  
createWord(mc+1+\_mc,word\*);  
} for (word\*=word[i++]);[/AS]
