# Positioning dynamically created MC's w/ variable height along y axis

**URL:** <https://forum.kirupa.com/t/positioning-dynamically-created-mcs-w-variable-height-along-y-axis/206325>\
**Category:** flash\
**Created:** [November 7, 2006, 5:06am UTC](https://forum.kirupa.com/t/positioning-dynamically-created-mcs-w-variable-height-along-y-axis/206325 "2006-11-07T05:06:03Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![SamSax](https://avatars.discourse-cdn.com/v4/letter/s/57b2e6/32.png) [@SamSax](https://forum.kirupa.com/u/SamSax)\
**Post date:** [November 7, 2006, 5:06am UTC](https://forum.kirupa.com/t/positioning-dynamically-created-mcs-w-variable-height-along-y-axis/206325/1 "2006-11-07T05:06:03Z")

</div>

My code works fine as long as all the dynamically created MC’s have the same height.

The following pulls in data from an array structured as such:

```auto

elements1= [
    {file:"image1.jpg", sequence:0, header: "", description:"Text One", VRname: "Sample1" }, 
    {file:"image2.jpg", sequence:1, header: "I'm a subheading", description:"Text Two", VRname: "Sample2" }, 
    {file:"image3.jpg", sequence:2, header: "", description:"Text Three", VRname: "Sample3" }, 
    {file:"image4.jpg", sequence:3, header: "", description:"Text four", VRname: "Sample4" }
    ]; 

arraySet = elements1

```

… to populate dyamically created text fields through this function:

```auto

function pickArray(arraySet) {
    for (i = 0; i < arraySet.length; i++) {
    listholder.createEmptyMovieClip(["MC"+i], i*2 );
    listholder["MC"+i].createTextField("vrname",this.getNextHighestDepth(),120,0,0,0);
    listholder["MC"+i].vrname.embedFonts = true
    listholder["MC"+i].vrname.text = arraySet*["VRname"] 
    listholder["MC"+i].vrname.autoSize = "right";
    listholder["MC"+i].vrname.selectable = false;
    listholder["MC"+i].vrname.setTextFormat(textAppearance);
    listholder["MC"+i]._y = (i * listholder["MC"+i]._height)

}

```

This works fine if all dynamically created MC’s have the same height. However, the code breaks as soon as I append information from the header category of my array with the following line:

```auto

listholder["MC"+i].vrname.text = arraySet*["VRname"] + "
" + arraySet*["header"]

```

Only one record in the array has information contained in the header category, so the height of the MC containing those two lines of text is greater than the others.

I tried numerous combinations to add each MC’s­­ height to the equation, but noting I attempt seems to work.

This:

```auto

listholder["MC"+i]._y = (i * listholder["MC"+i]._height) + listholder["MC"+i]._height

```

and this:

```auto

listholder["MC"+i]._y = (i * listholder["MC"+i]._height) + 44

```

only add values to the top of the list, pushing everything down from its initial y=0 position.

Searching the archives found an old posting from 2004 with the same issue, but seems to have gone unanswered:

> **[Dynamic positioning of XML text](https://www.kirupa.com/forum/showthread.php?t=72138&highlight=dynamic+positioning)**
>
> Got a web design/development question or just want to hang out with the most awesome people on the planet? Drop on in!

I may be going about this all wrong. I coded my app without realizing that some of my text links would require a main heading with sub links. So I’m not even sure this scenario will work. But I’ll deal with that issue later. Right now, this problem has bitten into me and I’m obsessed with finding a solution.

Hope anyone can help.

Thanks!
