# Loading text into scrolling XML gallery

**URL:** <https://forum.kirupa.com/t/loading-text-into-scrolling-xml-gallery/263753>\
**Category:** flash\
**Created:** [June 18, 2008, 9:46pm UTC](https://forum.kirupa.com/t/loading-text-into-scrolling-xml-gallery/263753 "2008-06-18T21:46:36Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Newbie20](https://avatars.discourse-cdn.com/v4/letter/n/ac8455/32.png) [@Newbie20](https://forum.kirupa.com/u/Newbie20)\
**Post date:** [June 18, 2008, 9:46pm UTC](https://forum.kirupa.com/t/loading-text-into-scrolling-xml-gallery/263753/1 "2008-06-18T21:46:36Z")

</div>

Hi Everyone,

I found this script that includes a scrolling thumbnail gallery. I only want the thumbnail part and i can make that work but i want to load some text in between each image. Is there a way to this? (My last resort is to turn the text into an image and load it thru xml like the other images but i don’t really want to do this.) Below is the script.

Thanks for your help!

[LEFT][COLOR=#f000f0]_/Code for loading XML file. /[/COLOR]  
[COLOR=#993300]function[/COLOR] loadXMLCOLOR=#000000[/COLOR] [COLOR=#000000]{[/COLOR]  
[COLOR=#993300]if[/COLOR] COLOR=#000000[/COLOR] [COLOR=#000000]{[/COLOR]  
[COLOR=#f000f0]/_ “xmlNode” is just a faster way of saying “this.firstChild”. _/_[/COLOR]  
[COLOR=#993300]xmlNode[/COLOR] = [COLOR=#993300]this[/COLOR].[COLOR=#993300]firstChild[/COLOR];  
image = [COLOR=#000000][[/COLOR][COLOR=#000000]][/COLOR];  
head = [COLOR=#000000][[/COLOR][COLOR=#000000]][/COLOR];  
description = [COLOR=#000000][[/COLOR][COLOR=#000000]][/COLOR];  
thumbnails = [COLOR=#000000][[/COLOR][COLOR=#000000]][/COLOR];  
category = [COLOR=#000000][[/COLOR][COLOR=#000000]][/COLOR];  
cat = [COLOR=#993300]xmlNode[/COLOR].[COLOR=#993300]childNodes[/COLOR][COLOR=#000000][[/COLOR][COLOR=#000000]0[/COLOR][COLOR=#000000]][/COLOR].[COLOR=#993300]firstChild[/COLOR].[COLOR=#993300]attributes[/COLOR].[COLOR=#000000]cid[/COLOR]  
[COLOR=#f000f0]_/_ Finds total number of child nodes (images w/captions to be displayed, in this case). _/_[/COLOR]  
total = [COLOR=#993300]xmlNode[/COLOR].[COLOR=#993300]childNodes[/COLOR][COLOR=#000000][[/COLOR][COLOR=#000000]1[/COLOR][COLOR=#000000]][/COLOR].[COLOR=#993300]childNodes[/COLOR].[COLOR=#993300]length[/COLOR];  
[COLOR=#f000f0]_/_ Extracts data from each child node, stopping when the total (defined above) is reached. _/_[/COLOR]  
[COLOR=#993300]for[/COLOR] [COLOR=#000000]([/COLOR]i=[COLOR=#000000]0[/COLOR]; i\<total; i++[COLOR=#000000])[/COLOR] [COLOR=#000000]{[/COLOR]  
image[COLOR=#000000][[/COLOR]i[COLOR=#000000]][/COLOR] = [COLOR=#0000ff]“images/”[/COLOR]+[COLOR=#993300]xmlNode[/COLOR].[COLOR=#993300]childNodes[/COLOR][COLOR=#000000][[/COLOR][COLOR=#000000]1[/COLOR][COLOR=#000000]][/COLOR].[COLOR=#993300]childNodes[/COLOR][COLOR=#000000][[/COLOR]i[COLOR=#000000]][/COLOR].[COLOR=#993300]childNodes[/COLOR][COLOR=#000000][[/COLOR][COLOR=#000000]0[/COLOR][COLOR=#000000]][/COLOR].[COLOR=#993300]firstChild[/COLOR].[COLOR=#993300]nodeValue[/COLOR];  
head[COLOR=#000000][[/COLOR]i[COLOR=#000000]][/COLOR] = [COLOR=#993300]xmlNode[/COLOR].[COLOR=#993300]childNodes[/COLOR][COLOR=#000000][[/COLOR][COLOR=#000000]1[/COLOR][COLOR=#000000]][/COLOR].[COLOR=#993300]childNodes[/COLOR][COLOR=#000000][[/COLOR]i[COLOR=#000000]][/COLOR].[COLOR=#993300]childNodes[/COLOR][COLOR=#000000][[/COLOR][COLOR=#000000]1[/COLOR][COLOR=#000000]][/COLOR].[COLOR=#993300]firstChild[/COLOR].[COLOR=#993300]nodeValue[/COLOR];  
description[COLOR=#000000][[/COLOR]i[COLOR=#000000]][/COLOR] = [COLOR=#993300]xmlNode[/COLOR].[COLOR=#993300]childNodes[/COLOR][COLOR=#000000][[/COLOR][COLOR=#000000]1[/COLOR][COLOR=#000000]][/COLOR].[COLOR=#993300]childNodes[/COLOR][COLOR=#000000][[/COLOR]i[COLOR=#000000]][/COLOR].[COLOR=#993300]childNodes[/COLOR][COLOR=#000000][[/COLOR][COLOR=#000000]2[/COLOR][COLOR=#000000]][/COLOR].[COLOR=#993300]firstChild[/COLOR].[COLOR=#993300]nodeValue[/COLOR];  
category[COLOR=#000000][[/COLOR]i[COLOR=#000000]][/COLOR] = [COLOR=#993300]xmlNode[/COLOR].[COLOR=#993300]childNodes[/COLOR][COLOR=#000000][[/COLOR][COLOR=#000000]1[/COLOR][COLOR=#000000]][/COLOR].[COLOR=#993300]childNodes[/COLOR][COLOR=#000000][[/COLOR]i[COLOR=#000000]][/COLOR].[COLOR=#993300]childNodes[/COLOR][COLOR=#000000][[/COLOR][COLOR=#000000]3[/COLOR][COLOR=#000000]][/COLOR].[COLOR=#993300]firstChild[/COLOR].[COLOR=#993300]nodeValue[/COLOR];  
thumbnails[COLOR=#000000][[/COLOR]i[COLOR=#000000]][/COLOR] = [COLOR=#0000ff]“images/th\_”[/COLOR]+[COLOR=#993300]xmlNode[/COLOR].[COLOR=#993300]childNodes[/COLOR][COLOR=#000000][[/COLOR][COLOR=#000000]1[/COLOR][COLOR=#000000]][/COLOR].[COLOR=#993300]childNodes[/COLOR][COLOR=#000000][[/COLOR]i[COLOR=#000000]][/COLOR].[COLOR=#993300]childNodes[/COLOR][COLOR=#000000][[/COLOR][COLOR=#000000]0[/COLOR][COLOR=#000000]][/COLOR].[COLOR=#993300]firstChild[/COLOR].[COLOR=#993300]nodeValue[/COLOR];  
thumbnails\_fnCOLOR=#000000[/COLOR];  
[COLOR=#000000]}[/COLOR]  
firstImageCOLOR=#000000[/COLOR];  
cat = [COLOR=#000000]0[/COLOR];  
[COLOR=#000000]}[/COLOR] [COLOR=#993300]else[/COLOR] [COLOR=#000000]{[/COLOR]  
content = [COLOR=#0000ff]“file not loaded!”[/COLOR];  
[COLOR=#000000]}[/COLOR]  
[COLOR=#000000]}[/COLOR]  
xmlData = [COLOR=#993300]new[/COLOR] [COLOR=#993300]XML[/COLOR]COLOR=#000000[/COLOR];  
xmlData.[COLOR=#993300]ignoreWhite[/COLOR] = [COLOR=#993300]true[/COLOR];  
xmlData.[COLOR=#993300]onLoad[/COLOR] = loadXML;  
xmlData.[COLOR=#993300]load[/COLOR]COLOR=#000000[/COLOR];  
[COLOR=#f000f0]_/////////////////////////////////////_[/COLOR]  
[COLOR=#f000f0]_/_ Lets the user scroll through with left and right arrow keys. _/_[/COLOR]  
listen = [COLOR=#993300]new[/COLOR] [COLOR=#993300]Object[/COLOR]COLOR=#000000[/COLOR];  
listen.[COLOR=#993300]onKeyDown[/COLOR] = [COLOR=#993300]function[/COLOR]COLOR=#000000[/COLOR] [COLOR=#000000]{[/COLOR]  
[COLOR=#993300]if[/COLOR] [COLOR=#000000]([/COLOR][COLOR=#993300]Key[/COLOR].[COLOR=#993300]getCode[/COLOR]COLOR=#000000[/COLOR] == [COLOR=#993300]Key[/COLOR].[COLOR=#993300]LEFT[/COLOR][COLOR=#000000])[/COLOR] [COLOR=#000000]{[/COLOR]  
prevImageCOLOR=#000000[/COLOR];  
[COLOR=#000000]}[/COLOR] [COLOR=#993300]else[/COLOR] [COLOR=#993300]if[/COLOR] [COLOR=#000000]([/COLOR][COLOR=#993300]Key[/COLOR].[COLOR=#993300]getCode[/COLOR]COLOR=#000000[/COLOR] == [COLOR=#993300]Key[/COLOR].[COLOR=#993300]RIGHT[/COLOR][COLOR=#000000])[/COLOR] [COLOR=#000000]{[/COLOR]  
nextImageCOLOR=#000000[/COLOR];  
[COLOR=#000000]}[/COLOR]  
[COLOR=#000000]}[/COLOR];  
[COLOR=#993300]Key[/COLOR].[COLOR=#993300]addListener[/COLOR]COLOR=#000000[/COLOR];  
[COLOR=#f000f0]_/_ Note the references to button instances previous\_btn and next\_btn here._/_[/COLOR]  
previous\_btn.[COLOR=#993300]onRelease[/COLOR] = [COLOR=#993300]function[/COLOR]COLOR=#000000[/COLOR] [COLOR=#000000]{[/COLOR]  
prevImageCOLOR=#000000[/COLOR];  
[COLOR=#000000]}[/COLOR];  
next\_btn.[COLOR=#993300]onRelease[/COLOR] = [COLOR=#993300]function[/COLOR]COLOR=#000000[/COLOR] [COLOR=#000000]{[/COLOR]  
nextImageCOLOR=#000000[/COLOR];  
[COLOR=#000000]}[/COLOR];  
[COLOR=#f000f0]_/////////////////////////////////////_[/COLOR]  
[COLOR=#f000f0]_/_ The movie begins, naturally, at the beginning–in XML, that’s zero! _/_[/COLOR]  
p = [COLOR=#000000]0[/COLOR];  
[COLOR=#f000f0]_/_ Preloader for images. _/_[/COLOR]  
[COLOR=#993300]this[/COLOR].[COLOR=#993300]onEnterFrame[/COLOR] = [COLOR=#993300]function[/COLOR]COLOR=#000000[/COLOR] [COLOR=#000000]{[/COLOR]  
filesize = picture.[COLOR=#993300]getBytesTotal[/COLOR]COLOR=#000000[/COLOR];  
[COLOR=#993300]loaded[/COLOR] = picture.[COLOR=#993300]getBytesLoaded[/COLOR]COLOR=#000000[/COLOR];  
preloader.[COLOR=#993300]\_visible[/COLOR] = [COLOR=#993300]true[/COLOR];  
[COLOR=#993300]if[/COLOR] [COLOR=#000000]([/COLOR][COLOR=#993300]loaded[/COLOR] != filesize[COLOR=#000000])[/COLOR] [COLOR=#000000]{[/COLOR]  
preloader.[COLOR=#993300]\_visible[/COLOR] = [COLOR=#993300]true[/COLOR];  
[COLOR=#000000]}[/COLOR] [COLOR=#993300]else[/COLOR] [COLOR=#000000]{[/COLOR]  
[COLOR=#f000f0]_/_ Makes preloader invisible once the image starts to fade in. _/_[/COLOR]  
preloader.[COLOR=#993300]\_visible[/COLOR] = [COLOR=#993300]false[/COLOR];  
[COLOR=#f000f0]_/_ Fade in the image. (If the alpha is under 100, add 10.) _/_[/COLOR]  
[COLOR=#993300]if[/COLOR] COLOR=#000000[/COLOR] [COLOR=#000000]{[/COLOR]  
picture.[COLOR=#993300]\_alpha[/COLOR] += [COLOR=#000000]10[/COLOR];  
[COLOR=#000000]}[/COLOR]  
[COLOR=#000000]}[/COLOR]  
[COLOR=#000000]}[/COLOR];  
[COLOR=#f000f0]_/_ Load & display the next image. It cleverly calculates whether you are at the end of the  
images or not. If you are, the script doesn’t run._/_[/COLOR]  
[COLOR=#993300]function[/COLOR] nextImageCOLOR=#000000[/COLOR] [COLOR=#000000]{[/COLOR]  
[COLOR=#f000f0]_/_ If it’s less than the total (the last image), let’s go ahead and load the next image. _/_[/COLOR]  
[COLOR=#993300]if[/COLOR] COLOR=#000000[/COLOR] [COLOR=#000000]{[/COLOR]  
p++;  
[COLOR=#993300]if[/COLOR] [COLOR=#000000]([/COLOR][COLOR=#993300]loaded[/COLOR] == filesize[COLOR=#000000])[/COLOR] [COLOR=#000000]{[/COLOR]  
[COLOR=#f000f0]_/_ If it is loaded, set alpha to zero, so that the preloader can fade it in! _/_[/COLOR]  
picture.[COLOR=#993300]\_alpha[/COLOR] = [COLOR=#000000]0[/COLOR];  
[COLOR=#f000f0]_/_ Put the image where it is supposed to go. _/_[/COLOR]  
picture.[COLOR=#993300]loadMovie[/COLOR][COLOR=#000000]([/COLOR]image[COLOR=#000000][[/COLOR]p[COLOR=#000000]][/COLOR], [COLOR=#000000]1[/COLOR][COLOR=#000000])[/COLOR];  
[COLOR=#f000f0]_/_ Load description into text box “desc\_txt” _/_[/COLOR]  
desc\_txt.[COLOR=#993300]text[/COLOR] = description[COLOR=#000000][[/COLOR]p[COLOR=#000000]][/COLOR];  
head\_txt.[COLOR=#993300]text[/COLOR] = head[COLOR=#000000][[/COLOR]p[COLOR=#000000]][/COLOR];  
[COLOR=#f000f0]_/_ Activates the function down below, telling you what number picture you’re viewing. _/_[/COLOR]  
picture\_numCOLOR=#000000[/COLOR];  
[COLOR=#000000]}[/COLOR]  
[COLOR=#000000]}[/COLOR]  
[COLOR=#000000]}[/COLOR]  
[COLOR=#f000f0]_/_ Basically the same as nextImage(), but backwards. Fading and image/text insertion is the same. _/_[/COLOR]  
[COLOR=#993300]function[/COLOR] prevImageCOLOR=#000000[/COLOR] [COLOR=#000000]{[/COLOR]  
[COLOR=#993300]if[/COLOR] COLOR=#000000[/COLOR] [COLOR=#000000]{[/COLOR]  
p–;  
picture.[COLOR=#993300]\_alpha[/COLOR] = [COLOR=#000000]0[/COLOR];  
picture.[COLOR=#993300]loadMovie[/COLOR][COLOR=#000000]([/COLOR]image[COLOR=#000000][[/COLOR]p[COLOR=#000000]][/COLOR], [COLOR=#000000]1[/COLOR][COLOR=#000000])[/COLOR];  
desc\_txt.[COLOR=#993300]text[/COLOR] = description[COLOR=#000000][[/COLOR]p[COLOR=#000000]][/COLOR];  
head\_txt.[COLOR=#993300]text[/COLOR] = head[COLOR=#000000][[/COLOR]p[COLOR=#000000]][/COLOR];  
picture\_numCOLOR=#000000[/COLOR];  
[COLOR=#000000]}[/COLOR]  
[COLOR=#000000]}[/COLOR]  
[COLOR=#f000f0]_/_ Automatically show the first image when the movie is loaded, fade-in and all. _/_[/COLOR]  
[COLOR=#993300]function[/COLOR] firstImageCOLOR=#000000[/COLOR] [COLOR=#000000]{[/COLOR]  
[COLOR=#993300]if[/COLOR] [COLOR=#000000]([/COLOR][COLOR=#993300]loaded[/COLOR] == filesize[COLOR=#000000])[/COLOR] [COLOR=#000000]{[/COLOR]  
picture.[COLOR=#993300]\_alpha[/COLOR] = [COLOR=#000000]0[/COLOR];  
[COLOR=#f000f0]_/_ Use image[0] instead of image[p] since this only applies to the first image. _/_[/COLOR]  
picture.[COLOR=#993300]loadMovie[/COLOR][COLOR=#000000]([/COLOR]image[COLOR=#000000][[/COLOR][COLOR=#000000]0[/COLOR][COLOR=#000000]][/COLOR], [COLOR=#000000]1[/COLOR][COLOR=#000000])[/COLOR];  
desc\_txt.[COLOR=#993300]text[/COLOR] = description[COLOR=#000000][[/COLOR][COLOR=#000000]0[/COLOR][COLOR=#000000]][/COLOR];  
head\_txt.[COLOR=#993300]text[/COLOR] = head[COLOR=#000000][[/COLOR][COLOR=#000000]0[/COLOR][COLOR=#000000]][/COLOR];  
picture\_numCOLOR=#000000[/COLOR];  
[COLOR=#000000]}[/COLOR]  
[COLOR=#000000]}[/COLOR]  
[COLOR=#f000f0]_/_ Thumbnail list. _/_[/COLOR]  
[COLOR=#993300]function[/COLOR] thumbnails\_fnCOLOR=#000000[/COLOR] [COLOR=#000000]{[/COLOR]  
thumbnail\_mc.[COLOR=#993300]createEmptyMovieClip[/COLOR][COLOR=#000000]([/COLOR][COLOR=#0000ff]“t”[/COLOR]+k, thumbnail\_mc.[COLOR=#993300]getNextHighestDepth[/COLOR]COLOR=#000000[/COLOR][COLOR=#000000])[/COLOR];  
tlistener = [COLOR=#993300]new[/COLOR] [COLOR=#993300]Object[/COLOR]COLOR=#000000[/COLOR];  
tlistener.[COLOR=#993300]onLoadInit[/COLOR] = [COLOR=#993300]function[/COLOR]COLOR=#000000[/COLOR] [COLOR=#000000]{[/COLOR]  
target\_mc.[COLOR=#993300]\_x[/COLOR] = hit\_left.[COLOR=#993300]\_x[/COLOR]+COLOR=#000000[/COLOR]_k;  
target\_mc.[COLOR=#000000]pictureValue[/COLOR] = k;  
target\_mc.[COLOR=#993300]onRelease[/COLOR] = [COLOR=#993300]function[/COLOR]COLOR=#000000[/COLOR] [COLOR=#000000]{[/COLOR]  
p = [COLOR=#993300]this[/COLOR].[COLOR=#000000]pictureValue[/COLOR]-[COLOR=#000000]1[/COLOR];  
nextImageCOLOR=#000000[/COLOR];  
[COLOR=#000000]}[/COLOR];  
target\_mc.[COLOR=#993300]\_alpha[/COLOR] = [COLOR=#000000]50[/COLOR];  
target\_mc.[COLOR=#993300]onRollOver[/COLOR] = [COLOR=#993300]function[/COLOR]COLOR=#000000[/COLOR] [COLOR=#000000]{[/COLOR]  
[COLOR=#993300]this[/COLOR].[COLOR=#993300]\_alpha[/COLOR] = [COLOR=#000000]100[/COLOR];  
thumbNailScrollerCOLOR=#000000[/COLOR];  
[COLOR=#000000]}[/COLOR];  
target\_mc.[COLOR=#993300]onRollOut[/COLOR] = [COLOR=#993300]function[/COLOR]COLOR=#000000[/COLOR] [COLOR=#000000]{[/COLOR]  
[COLOR=#993300]this[/COLOR].[COLOR=#993300]\_alpha[/COLOR] = [COLOR=#000000]50[/COLOR];  
[COLOR=#000000]}[/COLOR];  
[COLOR=#000000]}[/COLOR];  
image\_mcl = [COLOR=#993300]new[/COLOR] [COLOR=#993300]MovieClipLoader[/COLOR]COLOR=#000000[/COLOR];  
image\_mcl.[COLOR=#993300]addListener[/COLOR]COLOR=#000000[/COLOR];  
image\_mcl.[COLOR=#993300]loadClip[/COLOR][COLOR=#000000]([/COLOR]thumbnails[COLOR=#000000][[/COLOR]k[COLOR=#000000]][/COLOR], [COLOR=#0000ff]“thumbnail\_mc.t”[/COLOR]+k[COLOR=#000000])[/COLOR];  
[COLOR=#000000]}[/COLOR]  
[COLOR=#993300]function[/COLOR] thumbNailScrollerCOLOR=#000000[/COLOR] [COLOR=#000000]{[/COLOR]  
[COLOR=#f000f0]_// thumbnail code!_[/COLOR]  
[COLOR=#993300]this[/COLOR].[COLOR=#993300]createEmptyMovieClip[/COLOR][COLOR=#000000]([/COLOR][COLOR=#0000ff]“tscroller”[/COLOR], [COLOR=#000000]1000[/COLOR][COLOR=#000000])[/COLOR];  
scroll\_speed = [COLOR=#000000]10[/COLOR];  
tscroller.[COLOR=#993300]onEnterFrame[/COLOR] = [COLOR=#993300]function[/COLOR]COLOR=#000000[/COLOR] [COLOR=#000000]{[/COLOR]  
[COLOR=#993300]if[/COLOR] [COLOR=#000000]([/COLOR]COLOR=#000000[/COLOR] && COLOR=#000000[/COLOR][COLOR=#000000])[/COLOR] [COLOR=#000000]{[/COLOR]  
[COLOR=#993300]if[/COLOR] [COLOR=#000000]([/COLOR]COLOR=#000000[/COLOR] && COLOR=#000000[/COLOR][COLOR=#000000])[/COLOR] [COLOR=#000000]{[/COLOR]  
thumbnail\_mc.[COLOR=#993300]\_x[/COLOR] -= scroll\_speed;  
[COLOR=#000000]}[/COLOR] [COLOR=#993300]else[/COLOR] [COLOR=#993300]if[/COLOR] [COLOR=#000000]([/COLOR]COLOR=#000000[/COLOR] && COLOR=#000000[/COLOR][COLOR=#000000])[/COLOR] [COLOR=#000000]{[/COLOR]  
thumbnail\_mc.[COLOR=#993300]\_x[/COLOR] += scroll\_speed;  
[COLOR=#000000]}[/COLOR]  
[COLOR=#000000]}[/COLOR] [COLOR=#993300]else[/COLOR] [COLOR=#000000]{[/COLOR]  
[COLOR=#993300]delete[/COLOR] tscroller.[COLOR=#993300]onEnterFrame[/COLOR];  
[COLOR=#000000]}[/COLOR]  
[COLOR=#000000]}[/COLOR];  
[COLOR=#000000]}[/COLOR]  
[COLOR=#f000f0]_/\* Displays current position and total number of pictures. _/_[/COLOR]  
[COLOR=#993300]function[/COLOR] picture\_numCOLOR=#000000[/COLOR] [COLOR=#000000]{[/COLOR]  
current\_pos = p+[COLOR=#000000]1[/COLOR];  
pos\_txt.[COLOR=#993300]text[/COLOR] = current\_pos+[COLOR=#0000ff]" / "[/COLOR]+total;  
[COLOR=#000000]}[/COLOR]  
[/LEFT]
