How reference an array created in a loadXML within a listener?

Hi,

New to AS.

I’m trying to integrate this grid thumbnail gallery code with a full display.

I’m using CS3; code was originally intended for 8. Not sure if that’s relevant to my problem or not, but…:

I keep getting an error when I try to load the image from the image[] array within the tlistener.onLoadInit function. It comes back undefined, whether I use [variablename] or [#].

I’m guessing I need to reference the array differently because it’s in a function? I’ve tried a couple guesses like _parent.image[p], but to no happy outcome.

“picture.loadMovie(‘media\Full’+k+’.jpg’, 1)” Works by building the path manually and just changing the number part of it with a variable, but isn’t proper, and also forces me to use a file naming convention rather than just passing the filename via XML.

I pasted the AS below, the part in question marked off by “//??!!??!!??!!??!!”.

Any suggestions appreciated!

Thanks in advance,

:)Ben


main_menu.boton1._visible=false;
main_menu.boton2._visible=false;
main_menu.boton_reset._visible=false;
/////////////////////////////////////////////////////////////////////////////
function loadXML(loaded) {
if (loaded) {
xmlNode = this.firstChild;
thumbnails = [];
image = [];
title = [];
description = [];
_global.total = xmlNode.childNodes.length;
for (i=0; i<total; i++) {
thumbnails* = xmlNode.childNodes*.childNodes[0].firstChild.nodeValue;

// 1-!!??!!??!!??!!??!!??!!??!!??!!??!!??!!??!!??!!??!!??!!??!!??!!??!!??!!??!!??!!??!!??!!??
image* = xmlNode.childNodes*.childNodes[1].firstChild.nodeValue;
//!!??!!??!!??!!??!!??!!??!!??!!??!!??!!??!!??!!??!!??!!??!!??!!??!!??!!??!!??!!??!!??!!??

title* = xmlNode.childNodes*.childNodes[2].firstChild.nodeValue;
description* = xmlNode.childNodes*.childNodes[3].firstChild.nodeValue;
thumbnailer(i); trace(‘In loadXML - i=’+i+’–image*=’+image*);
}
firstImage(); //?need/wantt this here??
} else {
trace(“file not loaded!”);
}
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad =loadXML;
xmlData.load(“images2.xml”);

//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////// Load first
//p = 0;
//q=1;
this.onEnterFrame = function() {
//trace(‘enterframe’+q);
filesize = picture.getBytesTotal();
loaded = picture.getBytesLoaded();
//q++;
}; // nix, shortcircuit onEnterFrame?
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////load first image
function firstImage() {
if (loaded == filesize) {
picture._alpha = 100;
picture.loadMovie(image[0], 1);
title_txt.text = title[0];
caption_txt.text = description[0];
picture_num();
}
}

///////////////////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////////////////////
function thumbnailer(k){
//trace(‘at beg thumbNailer: k=’+k+’- image[k]=’+image[k]);
titleBGBar._alpha=50;

picXScale=100;
picYScale=100;
picX=260;
picY=15;

titleBGBar._x=picX;
titleBGBar._y=265;
titleBGBar._width = 325 * (picXScale/100);
titleBGBar._height = 25;
/*************************************************************used for altering demo. nix? incorporate?
picXScale=120;
picYScale=100;
picX=200;
picY=15;

titleBGBar._alpha=50;
titleBGBar._x=picX;
titleBGBar._y=266;
titleBGBar._width = 325 * (picXScale/100)+2 ;
titleBGBar._height = 25;
/* */
loaded_counter=0;
total_thumbs = _global.total;
var container = thumbnail_mc.createEmptyMovieClip(“th”+k,thumbnail_mc.getNextHighestDepth());
container._visible=false;
container._alpha=0;
var image = container.createEmptyMovieClip(“img”, container.getNextHighestDepth());
tlistener = new Object();
tlistener.onLoadInit = function(target_mc) {
// trace(‘target_mc=’+target_mc); // =‘s e.g. target_mc=_level0.main.thumbnail_mc.th8.img
// trace(‘k=’+k); //=‘s an integer 0 to totnum-1
// trace(‘at begin onLoadInit: k=’+k+’- _parent.image[k]=’+_parent.image[k]);
target_mc.pictureValue = k;
target_mc._alpha =100; //BMTN - set so all are dim/bright unless hover. use with onHover
target_mc.onRelease = function() {
p = this.pictureValue; // trace(‘p=’+p); trace(‘this.pictureValue=’+this.pictureValue); //='s integer 0 to …

// 2 - !!??!!??!!??!!??!!??!!??!!??!!??!!??!!??!!??!!??!!??!!??!!??!!??!!??!!??!!??!!??!!??!!??
picture.loadMovie(image[5], 1); //??? image[] comes up undefined, with k, p, #, _parent, this, etc. what am i missing?

picture.loadMovie(‘media\Full’+k+’.jpg’, 1); //Works, but isn’t proper… Also, forces use of file naming/numbering convention.

//!!??!!??!!??!!??!!??!!??!!??!!??!!??!!??!!??!!??!!??!!??!!??!!??!!??!!??!!??!!??!!??!!??

title_txt.text = title[k];
caption_txt.text = description[k];
picture._xscale=picXScale; //use for demoing different row/col numbers to adjust pics size
picture._yscale=picYScale;
picture._x=picX; //use for demoing different row/col numbers to adjust pics size
picture._y=picY;
title_txt._x=picX;
caption_txt._x=picX;
};
target_mc.onRollOver = function() {
this._alpha = 50;
};
target_mc.onRollOut = function() {
this._alpha = 100;
};
loaded_counter++;
counting_txt = loaded_counter;
if(loaded_counter==total_thumbs){
main_menu.boton1._visible=true;
main_menu.boton2._visible=true;
grid_maker_01(); //BMTN – force it to lay out thumbs in grid
}
};
image_mcl = new MovieClipLoader();
image_mcl.addListener(tlistener);
//orig: image_mcl.loadClip(thumbnails[k], “thumbnail_mc.th”+k+".img");
image_mcl.loadClip(thumbnails[k], “thumbnail_mc.th”+k+".img");
}

///////////////////////////////////////////////////////////////////////////////////////
MovieClip.prototype.grid_maker_01=function(f){
num=0;
col=3; row=3; // Toggle with set in thumbNailer to switch setup
//col=3; row=4;
//col=2; row=4;
scale=103;
space=7;
for (l=0;l<col;l++){
for (j=0;j<row;j++){
if(num<_global.total){
with(eval(“this.thumbnail_mc.th”+num)){
_x=((_width+space)*scale/100)*l;
_y=((_height+space)*scale/100)*j;
_xscale=_yscale=scale;
_visible=true;
}
num++;
}
}
}
this.cascader();
}
//////////////////////////////////////////////////////////////////////////////////
MovieClip.prototype.cascader=function(){
inter=115;
c=0;
delayed_fade=function(){
if (c<_global.total){
with(eval(“this.thumbnail_mc.th”+c)){
fadein();
}
c++;
}else{
main_menu.boton_reset._visible=true;
clearInterval(delay);
}
}
delay = setInterval(delayed_fade, inter);
}
///////////////////////////////////////////////////////////////////////////////
MovieClip.prototype.fadein=function(){
this.onEnterFrame=function(){
if (this._alpha<100){
this._alpha=this._alpha+5;
}else{
this._alpha=100;
delete this.onEnterFrame;
}
}
}
///////////////////////////////////////////////////////////////////////////////////////

/////////////////////////////////////////////////////////////////////////
function reset(){
for(d=0;d<_global.total;d++){
with(eval(“this.thumbnail_mc.th”+d)){
_x=0;
_y=0;
_alpha=0;
_xscale=100;
_yscale=100;
_rotation=0;
visible=false;
}
}
}