Im not sure what I’m doing wrong…
I have created an array on the first frame and have used the push method to push strings into the array. I am able to use the values in the array in the first frame. But when I call the array in the second array, it says ‘undefined’. What do I have to do to access the array in the first frame. I have also tried creating a global array.
//Frame 1
// variables for xml attributes
var entry = 0;
var total = 0;
var current = 0;
var scrollerTxt ="";
_global.imgarray = null;
var imgarray = new Array();
//load in XML
imageContent = new XML();
imageContent.ignoreWhite = true;
imageContent.load("images.xml");
imageContent.onLoad = function(success)
{
_root.total = this.firstChild.childNodes.length;
if (success) {
_root.entry = 0;
for (var i=0; i < _root.total; i++)
{
locate_txt = this.firstChild.childNodes[_root.entry].attributes.locate;
imgarray.push(locate_txt);
description_txt = this.firstChild.childNodes[_root.entry].attributes.description;
_root.entry++;
}
trace("imgArray[0]= " + imgarray[0]); //works
}
}
//Frame 2
myMCL = new MovieClipLoader(); //define MovieClipLoader
myListener = new Object(); //define listener
myListener.onLoadComplete = function(targetMC){
var loadProgress = myMCL.getProgress(targetMC);
myTrace (targetMC + " has finished loading.");
myTrace("Bytes loaded at end=" + loadProgress.bytesLoaded);
myTrace("Bytes total at end=" + loadProgress.bytesTotal);
targetMC.onPress = function() {
myTrace("targetMC = " + targetMC._name);
}
targetMC.onRollOver = function(){
targetMC._width = 200;
targetMC._height = 200;
}
targetMC.onRollOut = function(){
targetMC._width = 100;
targetMC._height = 100;
}
}
function initClips(){
for (i=1; i<=4; i++){
var j = i - 1;
this.attachMovie("img", "img" + i, i);
this["img"+i]._x = i*110;
myMCL.loadClip(_root.imgarray[j], this["img"+i]);
trace("array[" + j+"]= " + _root.imgarray[j]); //doesnt work
}
}
myMCL.addListener(myListener);
initClips();