# Problems with dynamically making \_mc's with centing function

**URL:** <https://forum.kirupa.com/t/problems-with-dynamically-making--mcs-with-centing-function/218589>\
**Category:** Uncategorized\
**Created:** [March 9, 2007, 1:05am UTC](https://forum.kirupa.com/t/problems-with-dynamically-making--mcs-with-centing-function/218589 "2007-03-09T01:05:53Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![joshchernoff](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/joshchernoff/32/1852_2.png) [@joshchernoff](https://forum.kirupa.com/u/joshchernoff)\
**Post date:** [March 9, 2007, 1:05am UTC](https://forum.kirupa.com/t/problems-with-dynamically-making--mcs-with-centing-function/218589/1 "2007-03-09T01:05:53Z")

</div>

edit update resolved:::::::::::::::::::::::::::::::::::::::::

problem with code below  
delete onLoadInit  
remove that and it works fine.

function onLoadInit wont work, and I don’t know why.  
Any help would be great.

fyi:  
this is a function that makes a dynamically named \_mc on the stage.  
Then loads a jpg in to the \_mc(“holder”) nested inside of the main \_mc (“test\_mc”). After words it centers the \_mc “holder” where that the index(x,y point) of the main \_mc “test\_mc” is centered over the image loaded.

This works fine when not using array access notation, but since I need to name the \_mc’s dynamical I have no idea how to other wise.

when calling the addImage function pass it to strings  
1: the name of the \_mc you wish to make. needs to be a :String  
2: the url of the image you wish to load. needs to be a :String

```auto

addImage("test_mc","tes1.jpg");
function addImage(mc:String,imageName:String) {
    var Image:String = mc;
    var ImageName:String = imageName;
    var nIndex:Number = this.getNextHighestDepth();
    
    var image:MovieClip = this.createEmptyMovieClip(Image, nIndex);
    var holder:MovieClip = this[Image].createEmptyMovieClip("holder", nIndex);
    
    var mcLoader:MovieClipLoader = new MovieClipLoader();
    mcLoader.addListener(this);
    mcLoader.loadClip(ImageName, this[Image]["holder"]);
    function onLoadInit(mc:MovieClip){ //<---- heres the problem:: cant't get this to function
        trace("test");
        this[Image]["holder"]._y = -this[Image]._height/2;
        this[Image]["holder"]._x = -this[Image]._width/2;
        this[Image]._y = Stage.height/2; 
        this[Image]._x = Stage.width/2; 
    }
}

```
