Populate combobox

Is there a way to load an external txt file into a combo box.

Well of course. Why not? After all it is just text that you are entering in your combobox…

pom :smirk:

Well, would you mind letting me in on your secret.=)

Open your ears…

You need: a text file with the things you want to put in the combobox. I called the file combotext.txt and it contains

They are formatted like so: varName=label_data.

Then in the flash file, you need a combobox, instance name myCombo.

Finally, some code in the 1st frame of the movie:

//create loadvars object
myLV=new LoadVars();
	//gets all the elements of the txt file
	for (var i in myLV){
		trace (i+": "+this*);
		//split the label from the data
		var a=this*.split("_");
		//fill the combobox
		//for the demo

	//display the data of the selected item
	var res=c.getSelectedItem().data[0];

Tada!! There’s just one little problem, I let you find it :cowboy:

pom :stuck_out_tongue:

I’ll be back.:asian:

My pleasure…

Problem 1

The  data values from the text files are reversed.

Ok, I have changed the .split"_" to .split"|"

My txt file reads,


When I render the fla and select song1, I receive an output of 4.
It should be 1?

Problem 2

I always have 1 extra label in the list box.
You see in my text file I only have 4 rows, but when I render the fla I have 5 rows in the listbox and the 5th row has an output of undefined.

Well what do you think?


Can I have more then 2 values in my txt file.
Like, label | data | more data.