# Centering Dynamic Images in XML Gallery

**URL:** https://forum.kirupa.com/t/centering-dynamic-images-in-xml-gallery/204783
**Category:** flash
**Created:** [October 23, 2006, 2:30pm UTC](https://forum.kirupa.com/t/centering-dynamic-images-in-xml-gallery/204783 "2006-10-23T14:30:22Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![citruscomputers](https://avatars.discourse-cdn.com/v4/letter/c/4491bb/32.png) [@citruscomputers](https://forum.kirupa.com/u/citruscomputers)
#### Post date: [October 23, 2006, 2:30pm UTC](https://forum.kirupa.com/t/centering-dynamic-images-in-xml-gallery/204783/1 "2006-10-23T14:30:22Z")

</div>

Hey there folks, I’m having an issue centering dynamically loaded content, if anyone could take a look at this gallery movie I’m working on I would appreciate it.

[http://www.citruswebhosting.com/web-test/imgCenter.zip](http://www.citruswebhosting.com/web-test/imgCenter.zip)

Heres the AS for the gallery, I’m trying to center each image upon loading it into the img container.

```auto
var cx = loader._x;
myPhoto = new XML();
myPhoto.ignoreWhite = true;
myPhoto.onLoad = function(success) {
    //portfolioTag = this.firstChild;
    numimages = this.firstChild.childNodes.length;
    spacing = 50;
    for (i=0; i<numimages; i++) {
        this.picHolder = this.firstChild.childNodes*;
        this.thumbHolder = thumbnails.createEmptyMovieClip("thumbnail"+i, i);
        this.thumbHolder._x = i*spacing;
        this.thumbLoader = this.thumbHolder.createEmptyMovieClip("thumbnail_image", 0);
        this.thumbLoader.loadMovie(this.picHolder.attributes.thmb);
        this.thumbHolder.title = this.picHolder.attributes.title;
        this.thumbHolder.main = this.picHolder.attributes.main;
        this.thumbHolder.onRelease = function() {
            loader.loadMovie(this.main);
            loader._x = cx-loader._width/2;
            };
        }    
        
            
    };

myPhoto.load("xmlphoto.xml");

```

---

<div class="post-metadata">

### Author: ![citruscomputers](https://avatars.discourse-cdn.com/v4/letter/c/4491bb/32.png) [@citruscomputers](https://forum.kirupa.com/u/citruscomputers)
#### Post date: [October 24, 2006, 12:39pm UTC](https://forum.kirupa.com/t/centering-dynamic-images-in-xml-gallery/204783/2 "2006-10-24T12:39:29Z")

</div>

bump, would really appreciate some help with this code. Thanks in advance!  
-alex
