setDataProvider()

Hi All,

setDataProvider is now not working. I have some code that sets a combobox data to an array. Like so:



comboBox.setDataProvider(myArray);


This code was working just fine when it is was main movie, but now I have loaded this movie into a main movie and the comboBox is not being populated. The array “myArray” is being created in the same timeline as the comboBox.

Any ideas for troubleshooting?

Ok here’s some code. The code is on the 1st frame of a mc called “JukeBox”. The comboBox is on another layer of the mc “JukeBox”. The code works great if I just publish it, but if I load it into another swf file the setDataProvider function is not populating the comboBox.

[AS]

#initclip
function JukeBoxClass() {
this.init();
}
JukeBoxClass.prototype = new MovieClip();
JukeBoxClass.prototype.init = function() {

comboBox = this.comboBox;
songList = this.songList;
songNumber = this.songNumber;

songList = new Array();
songList[0] = “Winter’s Ending”;
songList[1] = “Better Than This”;
songList[2] = “All My Songs”;
songList[3] = “I Wonder”;
songList[4] = “Tipton’s”;
songList[5] = “Regarding Miranda”;
songList[6] = “Power of the Gospel”;
songList[7] = “The Band”;
songList[8] = “I Prefer”;
songList[9] = “Home Sweet Road”;
comboBox.onLoad = function(){
this.setRowCount(8);
this.setDataProvider(songList);
this.setSelectedIndex(songNumber);
this.setChangeHandler(“comboBoxChangeHandler”);
}
}

Object.registerClass(“JukeBox”, JukeBoxClass);
#endinitclip

[/AS]

A wild guess… :stuck_out_tongue:

Try removing the [font=courier new]onLoad[/font] event handler.

JukeBoxClass.prototype.init = function() {
	comboBox = this.comboBox;
	songList = this.songList;
	songNumber = this.songNumber;
	songList = new Array();
	// ...
	songList[9] = "Home Sweet Road";
	comboBox.setRowCount(8);
	comboBox.setDataProvider(songList);
	comboBox.setSelectedIndex(songNumber);
	comboBox.setChangeHandler("comboBoxChangeHandler");
};

You know I haven’t tried that. I’ll check it out kode.

Well kode/claudio… I’m back. Same problem still. I did quite a bit of testing over the weekend. I got it to work correctly as initially coded when I load the Jukebox swf into my main swf by means of _levels. It will not work when I load it into a target mc. Weird hunh? Right now I am debating whether to rewrite some of my code to handle levels now or keep tackling this setDataProvider issue. Frustrating… Another other suggestions.

Try using relative addressing ([font=courier new]this[/font] and/or [font=courier new]_parent[/font] instead of [font=courier new]_root[/font]). :-\