# \[Flash CS4 AS2\] Tried to alter code of FLash/xml gallery - where did I go wrong?

**URL:** <https://forum.kirupa.com/t/flash-cs4-as2-tried-to-alter-code-of-flash-xml-gallery-where-did-i-go-wrong/306927>\
**Category:** flash\
**Created:** [March 24, 2010, 5:40pm UTC](https://forum.kirupa.com/t/flash-cs4-as2-tried-to-alter-code-of-flash-xml-gallery-where-did-i-go-wrong/306927 "2010-03-24T17:40:35Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![timmay2606](https://avatars.discourse-cdn.com/v4/letter/t/a6a055/32.png) [@timmay2606](https://forum.kirupa.com/u/timmay2606)\
**Post date:** [March 24, 2010, 5:40pm UTC](https://forum.kirupa.com/t/flash-cs4-as2-tried-to-alter-code-of-flash-xml-gallery-where-did-i-go-wrong/306927/1 "2010-03-24T17:40:35Z")

</div>

Hi Folks,

I followed Kirupa’s excellent tutorial on integrating XML into a Flash gallery ([kirupa.com - XML and Flash Photogallery, Page 1](http://www.kirupa.com/developer/mx2004/xml_flash_photogallery.htm)). All went well on the tutorial, and I understood the concepts (or so I thought!).

However I didn’t want text in my gallery, and wanted to experiment with thumbnails. So i deleted the text fields layer, and got rid of all of the AS2 code relating to it. I also just to be on the safe side took the descriptions out of the XML. I created a new XML node for thumbnails (tn) and created a movieclip elsewhere on the stage in it’s own layer for the thumbs, which I called tn.

At this point I would b happy if it just showed the thumb at the same time as the main image, so I copied anythjing refering to the image node and changed the copied script to tn where appropriate.

However when I test the movie there is no sign of the thumbs. Can anybody tell me where I’ve gone wrong?

AS2 script and XML below

> function loadXML(loaded) {  
> if (loaded) {  
> xmlNode = this.firstChild;  
> image = ;  
> tn = ;  
> total = xmlNode.childNodes.length;  
> for (i=0; i\<total; i++) {  
> image\* = xmlNode.childNodes\*.childNodes[0].firstChild.nodeValue;  
> tn\* = xmlnode.childNodes\*.childNodes[1].firstChild.nodeValue;}  
> firstImage();  
> } else {  
> content = “file not loaded!”;  
> }  
> }  
> xmlData = new XML();  
> xmlData.ignoreWhite = true;  
> xmlData.onLoad = loadXML;  
> xmlData.load(“images.xml”);  
> /////////////////////////////////////  
> listen = new Object();  
> listen.onKeyDown = function() {  
> if (Key.getCode() == Key.LEFT) {  
> prevImage();  
> } else if (Key.getCode() == Key.RIGHT) {  
> nextImage();  
> }  
> };  
> Key.addListener(listen);  
> previous\_btn.onRelease = function() {  
> prevImage();  
> };  
> next\_btn.onRelease = function() {  
> nextImage();  
> };  
> /////////////////////////////////////  
> p = 0;  
> this.onEnterFrame = function() {  
> filesize = picture.getBytesTotal();  
> loaded = picture.getBytesLoaded();  
> preloader.\_visible = true;  
> if (loaded != filesize) {  
> preloader.preload\_bar.\_xscale = 100\*loaded/filesize;  
> } else {  
> preloader.\_visible = false;  
> if (picture.\_alpha\<100) {  
> picture.\_alpha += 10;}  
> if (tn.\_alpha\<100) {  
> tn.\_alpha += 10;}  
> }  
> };  
> function nextImage() {  
> if (p\<(total-1)) {  
> p++;  
> if (loaded == filesize) {  
> picture.\_alpha = 0;  
> picture.loadMovie(image[p], 1);  
> tn.\_alpha = 0;  
> tn.loadMovie(tn[p], 1);  
> picture\_num();  
> }  
> }  
> }  
> function prevImage() {  
> if (p\>0) {  
> p–;  
> picture.\_alpha = 0;  
> picture.loadMovie(image[p], 1);  
> tn.\_alpha = 0;  
> tn.loadMovie(tn[p], 1);  
> picture\_num();  
> }  
> }  
> function firstImage() {  
> if (loaded == filesize) {  
> picture.\_alpha = 0;  
> picture.loadMovie(image[0], 1);  
> tn.\_alpha = 0;  
> tn.loadMovie(tn[0], 1);  
> picture\_num();  
> }  
> }  
> function picture\_num() {  
> current\_pos = p+1;  
> pos\_txt.text = current\_pos+" / "+total;  
> }

> \<?xml version=“1.0” encoding=“UTF-8” standalone=“yes”?\>  
> \<images xmlns:xsi=“[http://www.w3.org/2001/XMLSchema-instance](http://www.w3.org/2001/XMLSchema-instance)”\>  
> \<pic\>  
> \<image\>LargeImageFiles/001\_1.jpg\</image\>  
> \<tn\>Thumbnails/001\_1\_tn.jpg\</tn\>  
> \</pic\>  
> \<pic\>  
> \<image\>LargeImageFiles/002\_2.jpg\</image\>  
> \<tn\>Thumbnails/002\_2\_tn.jpg\</tn\>  
> \</pic\>  
> \<pic\>  
> \<image\>LargeImageFiles/003\_3.jpg\</image\>  
> \<tn\>Thumbnails/003\_3\_tn.jpg\</tn\>  
> \</pic\>  
> \<pic\>  
> \<image\>LargeImageFiles/004\_4.jpg\</image\>  
> \<tn\>Thumbnails/004\_4\_tn.jpg\</tn\>  
> \</pic\>  
> \<pic\>  
> \<image\>LargeImageFiles/005\_5.jpg\</image\>  
> \<tn\>Thumbnails/005\_5\_tn.jpg\</tn\>  
> \</pic\>  
> \<pic\>  
> \<image\>LargeImageFiles/006\_6.jpg\</image\>  
> \<tn\>Thumbnails/006\_6\_tn.jpg\</tn\>  
> \</pic\>  
> \<pic\>  
> \<image\>LargeImageFiles/007\_7.jpg\</image\>  
> \<tn\>Thumbnails/007\_7\_tn.jpg\</tn\>  
> \</pic\>  
> \</images\>

Any help would be appreciated,

Timmay
