I have a little picture viewer that I built that loads pictures from an array.
When I define the array contents within Flash, it runs beautifully. When I try to build the array with the same contents from an external text file, however, it says it can't find the pictures.
Here's the array, built in Flash, that works just fine:
ActionScript Code:
var picNames: Array = ["hotel1.jpg",
"hotel3.jpg",
"smores.jpg",
"sunday1.jpg"];
Here's the code I'm using to bring in the same information in from an external text file:
ActionScript Code:
picsLVs = new LoadVars();
picsLVs.load("pics.txt");
picsLVs.onLoad = function(success:Boolean):Void {
if (success) {
var picNames: Array = new Array(); //create picture name array from loaded text file
picNames = this.pictures.split(",");
} else {
trace("Error loading/parsing LoadVars.");
} //end if
} //end onLoad function
And here's the contents of pics.txt (the text file I'm loading):
Code:
pictures="hotel1.jpg","hotel3.jpg","smores.jpg","sunday1.jpg"
The text file appears to load properly. If I trace the contents of the array within the onLoad function, it correctly displays the array as the contents of the imported text file.
If I trace the contents of the array outside the onLoad function, however, it returns the length of the array as "0" and the elements as "undefined", so for some reason, the array does not stay defined outside of the onLoad.
Any ideas?
TIA,
Carolyn