# Setting functions in a loop

**URL:** https://forum.kirupa.com/t/setting-functions-in-a-loop/251449
**Category:** flash
**Created:** [February 8, 2008, 4:07pm UTC](https://forum.kirupa.com/t/setting-functions-in-a-loop/251449 "2008-02-08T16:07:39Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Voursez](https://avatars.discourse-cdn.com/v4/letter/v/b5ac83/32.png) [@Voursez](https://forum.kirupa.com/u/Voursez)
#### Post date: [February 8, 2008, 4:07pm UTC](https://forum.kirupa.com/t/setting-functions-in-a-loop/251449/1 "2008-02-08T16:07:39Z")

</div>

Hey people

I’m trying to set some rollover functions to duplicated mc’s inside a loop. There is probably some logic as to why it doesn’t work, I just don’t see it. The rollover function only gets applied to the last image/mc duplicated. Some help would be nice, thanks.

[AS]  
xml.onLoad = function() {  
nodes = this.firstChild.childNodes;  
for(i=0; i\<nodes.length; i++){  
temp\_inst = testthingy.duplicateMovieClip(“thumb”+i, i);  
temp\_inst.\_x = xPos;  
temp\_inst.\_y = 0;  
var mcListener:Object = new Object();  
mcListener.onLoadInit = function(){  
temp\_inst.onRollOver = function(){  
trace(“weeee”);  
}  
}  
var mcLoader:MovieClipLoader = new MovieClipLoader();  
mcLoader.addListener(mcListener);  
mcLoader.loadClip(nodes\*.attributes.url, temp\_inst);

```
	xPos += parseInt(nodes*.attributes.width);
}

```

}  
[/AS]
