# Code help please!

**URL:** <https://forum.kirupa.com/t/code-help-please/111459>\
**Category:** Uncategorized\
**Created:** [May 27, 2004, 4:05am UTC](https://forum.kirupa.com/t/code-help-please/111459 "2004-05-27T04:05:27Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![snaphappy](https://avatars.discourse-cdn.com/v4/letter/s/ed8c4c/32.png) [@snaphappy](https://forum.kirupa.com/u/snaphappy)\
**Post date:** [May 27, 2004, 4:05am UTC](https://forum.kirupa.com/t/code-help-please/111459/1 "2004-05-27T04:05:27Z")

</div>

I am loading an array from a text file to create a set of thumbnail images a la scotty’s excellent post on the topic, using this code:

function select(q) {  
thumb\_array = new Array();  
loadArray = new LoadVars();  
loadArray.load(“array.txt”);  
loadArray.onLoad = function(success) {  
if (success) {  
ab = this[“array\_”+q];  
thumb\_array = ab.split(",");  
\_root.image\_array = thumb\_array;  
posthumbs();  
}  
};  
}

with the following in the .txt file

array\_1=001,002,003,005&array\_2=004,005,091,092,093,094,095,096,

As far as I understand the top function makes array\_1 and array\_2 selectable, and they are then referenced by this button action

contents.onRelease = function() {  
\_root.dragwindow.scrll.select(1);  
};

What I need help with is trying to have the same functionality but using XML, I understand how to load arrays from an xml file, but can’t get it to tie in with everything else even after many long attempts.

I also don’t understand what is going on later in the code with ab, can anyone explain it?

COMPLETE CODE FOLLOWS:

(attached as zipped text file - post.zip)

any help or explanations truly appreciated.

SH

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [May 27, 2004, 7:06pm UTC](https://forum.kirupa.com/t/code-help-please/111459/2 "2004-05-27T19:06:20Z")

</div>

one step forward…two steps back

a little further in my understanding (I think) here is the commented code (as I understand it):

function select(q) {

//create array  
thumb\_array = new Array();

//load array from text file  
loadArray = new LoadVars();  
loadArray.load(“array.txt”);

//evaluate if text file has loaded  
loadArray.onLoad = function(success) {

if (success) {  
//make it possible to get array through select e.g select(1) = array\_1  
//and assign that array as the value of ab  
ab = this[“array\_”+q];

//create the thumb array by breaking apart array\_1 to become  
[//001.jpg](https://001.jpg),002.jpg etc.  
thumb\_array = ab.split(",");  
//trace(ab);

//set the image\_array at root to equal thumb\_array (001.jpg,002.jpg etc.)  
\_root.image\_array = thumb\_array;

//initiate the function to make thumbnail buttons  
posthumbs();  
}  
};  
}

so now I believe that I need nested arrays in XML to produce the same effect, but don’t understand how to make these so they are selectable through the function select(). Pretty sure it has something with nodes but it is still beyond my understanding.

Any help going?
