# setDataProvider()

**URL:** <https://forum.kirupa.com/t/setdataprovider/96617>\
**Category:** Uncategorized\
**Created:** [December 11, 2003, 5:11pm UTC](https://forum.kirupa.com/t/setdataprovider/96617 "2003-12-11T17:11:05Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![andrthad](https://avatars.discourse-cdn.com/v4/letter/a/e480ec/32.png) [@andrthad](https://forum.kirupa.com/u/andrthad)\
**Post date:** [December 11, 2003, 5:11pm UTC](https://forum.kirupa.com/t/setdataprovider/96617/1 "2003-12-11T17:11:05Z")

</div>

Hi All,

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

```auto

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?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [December 12, 2003, 5:59am UTC](https://forum.kirupa.com/t/setdataprovider/96617/2 "2003-12-12T05:59:34Z")

</div>

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]

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [December 12, 2003, 6:18am UTC](https://forum.kirupa.com/t/setdataprovider/96617/3 "2003-12-12T06:18:08Z")

</div>

A wild guess… 😛

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

```auto
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");
};

```

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [December 12, 2003, 8:32pm UTC](https://forum.kirupa.com/t/setdataprovider/96617/4 "2003-12-12T20:32:52Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [December 15, 2003, 9:51pm UTC](https://forum.kirupa.com/t/setdataprovider/96617/5 "2003-12-15T21:51:21Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [December 16, 2003, 6:34am UTC](https://forum.kirupa.com/t/setdataprovider/96617/6 "2003-12-16T06:34:03Z")

</div>

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