# XML gallery variable img width

**URL:** <https://forum.kirupa.com/t/xml-gallery-variable-img-width/308728>\
**Category:** flash\
**Created:** [April 28, 2010, 11:03pm UTC](https://forum.kirupa.com/t/xml-gallery-variable-img-width/308728 "2010-04-28T23:03:26Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gandarufu](https://avatars.discourse-cdn.com/v4/letter/g/bc8723/32.png) [@Gandarufu](https://forum.kirupa.com/u/Gandarufu)\
**Post date:** [April 28, 2010, 11:03pm UTC](https://forum.kirupa.com/t/xml-gallery-variable-img-width/308728/1 "2010-04-28T23:03:26Z")

</div>

hi there folks,

i’m a complete noob when it comes to scripting.  
i’m working on a XML gallery. it’s supposed to read the images from the xml and then add them to a holder\_mc.

my only problem is that i cannot work out how i could manage to make the new clips appear next to the old one with a space of lik 50 px between them. i wanna keep it variable to some extend.

so, here’s the xml

```php
<?xml version="1.0" encoding="utf-8"?>
<easeslide>
    <data>
        <image>images/01.jpg</image>
        <width>326</width>
    </data>
    <data>
        <image>images/02.jpg</image>
        <width>490</width>
    </data>
    <data>
        <image>images/03.jpg</image>
        <width>490</width>
    </data>
</easeslide>

```

then, in flash i’m having a little trouble. the code was working with a fixed image-width, so it said

```php

loadContainers = function(){
        var mcload_w = content_mc.mcload0._width;
        var myAmount = total - 1;
        
        for(var i=1;i<=myAmount;i++){
        
        duplicateMovieClip(content_mc.mcload0,"mcload"+i,i);
        content_mc["mcload"+i]._width = imgwidth*;
        content_mc["mcload"+i]._x = (content_mc.mcload0._x +(mcload_w*(i)));
        content_mc["mcload"+i]._y = 0;
        }
}

```

now i figured, that if i want to keep it dynamic, i could create a var that tells the new instance of “i” its \_x cordinate by summing up

```php
[i-1]._x + imgwidth[i-1]

```

but i don’t know how to write it properly in flash. if i trace what i’ve been trying here it says NaN.

```php
content_mc["mcload"+(i-1)]._x + imgwidth[i-1]

```

oh my, you guys must have a blast reading this nooby-\*\*\*\*.  
nevertheless, if someone could help me out i’d be more than grateful : ))

thanks in advance,  
cheers,  
gandarufu
