day|&day0&date0=07/01/2003&bn0=We Rock This Town&
day|&day1&date1=07/02/2003&bn1=Rocketsl&
day|&day3&date3=07/05/2003&bn3=Rockers&
day|&day4&date4=07/05/2003&bn4=Hip Hop&
home = new LoadVars();
homeURL = "the text file"
home.load(homeURL);
home.onLoad = function(success) {
if (success) {
myArray = new Array();
for (i=0; i-1<this.NUMITEMS; i++) {
var date = eval("this.date"+i);
var name = eval("this.bn"+i);
myArray* = [date, name];
var DataProvider = {date:myArray*[0], bn:myArray*[1]}
pullDay.addItem(myArray*[0], DataProvider);
Now when I run this code, the listbox I am populating with the array information looks like this:
07/01/2003
07/02/2003
object object
object object
As you can see since I am not following a 1,2,3,4,5 order in the array, flash does not know what to do with the rest of the data. Is there a way around this?
The for loop looks like it’s assigning information into your array and probably setting position 2 to undefined as there is no matching data in the text file, so prior to pulling the information into your listbox check to see if it’s valid.
for (i=0; i-1<this.NUMITEMS; i++) {
var date = eval("this.date"+i);
var name = eval("this.bn"+i);
if(date != undefined){
myArray* = [date, name];
var DataProvider = {date:myArray*[0], bn:myArray*[1]}
pullDay.addItem(myArray*[0], DataProvider);
I set my NUMITEMS to 31 because I am working with days of the month. So the code above loops through 1-31 and only shows the days that are in the array file.