# Function + Pointers

**URL:** <https://forum.kirupa.com/t/function-pointers/276449>\
**Category:** flash\
**Created:** [November 27, 2008, 3:09pm UTC](https://forum.kirupa.com/t/function-pointers/276449 "2008-11-27T15:09:01Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![o0oo](https://avatars.discourse-cdn.com/v4/letter/o/d6d6ee/32.png) [@o0oo](https://forum.kirupa.com/u/o0oo)\
**Post date:** [November 27, 2008, 3:09pm UTC](https://forum.kirupa.com/t/function-pointers/276449/1 "2008-11-27T15:09:01Z")

</div>

I have a loop and I am trying to create dynamic functions, each which contains a different variable. The problem is, once the loop finishes, it references the function created last.

I trimmed the code down below, but it should illustrate what I am trying to do.

```auto

// start segment
for(var j=0;j<ary.length;j++) {
    var img_mc:MovieClip = new MovieClip();
                
    var temp_str:String = "testing_" + j;
    launchBanner(img_mc,temp_str);
}

// end segment

function launchBanner(object:MovieClip, temp_str:String):void {
    var f:Function = new Function();
    f = function(e:MouseEvent) { trace(mc_url); };
    object.addEventListener(MouseEvent.CLICK, f );    
}

```
