ComboBox Q

Hey, I wonderd if it was possible to do so when clicking on one of the options in the ComboBox, it could load an .swf into an container?

Maybe with:

container.loadMovie("sound.swf");

Or something…

Thanks,
fatnslow

Anyone?

nope, dont know how to do that…

have you checked the FMX default help files?
surely there is something like comboBox.onChange…??

Prophet.

Couldn’t find it…

Noone knows how to do it? Read that in MX2004 you could use On change, but it doesnt work in MX, so anyone know?

yes it is possible! here is the code you need for the frame where the combobox is positioned:


function handler () {
	chosen = box.getSelectedItem().label;
	if(chosen == "theoptionfromthecombobox"){
		container.loadMovie("sound.swf");
	}
}

the instancename of the combobox has to be box. and has to have the label theoptionfromthecombobox. if you don’t get it… just post a message. for Change Handler you have to fill in handler by Parameters. because handler is the name of the function. if you don’t get it… just post a message.

Hmm, didnt get it :slight_smile:

Do I have to have one of those AS for each swf i want to load? Since “theoptionfromthecombobox” is just one label…

I have tried alittle now, but can’t get how it works, could you post how you do it, or make an small fla with just the combobox?

With more than one label.

Thanks,
fatnslow

i’m going away now for about 6 hours, when i get back i’ll make that fla :smiley:

Ok

well here it is then! go to http://thomas.zeal-music.com/flash and then “save-target-as” combo.fla. have fun!

Thanks, but how do I get it to load another .swf on label 2? I have tried copying it so I have to codes and then change label to sound2:

 
function handler () {
 // this function will be called when you choose an item
 chosen = combobox.getSelectedItem().label;
 // difine var chosen
 // chosen is the label you selected from ComboBox "combobox"
 // a label you can define at the parameters tab at the properties of a ComboBox
 if(chosen == "sound1"){
  // if item/label soudn1 is selected then
  container.loadMovie("sound.swf");
  // load movie sound.swf into mc container
 }
}
function handler () {
 // this function will be called when you choose an item
 chosen = combobox.getSelectedItem().label;
 // difine var chosen
 // chosen is the label you selected from ComboBox "combobox"
 // a label you can define at the parameters tab at the properties of a ComboBox
 if(chosen == "sound2"){
  // if item/label soudn1 is selected then
  container.loadMovie("sound2.swf");
  // load movie sound.swf into mc container
 }
}

But it only loads one of them, so how can I get it to load another .swf on another label?

Appreciate all help,
fatnslow

Nm, I found it out, just used else if. Probably some easier way, but this works for me atleast :slight_smile:

 
function handler() {
	chosen = combobox.getSelectedItem().label;
	if (chosen == "sound1") {
		container.loadMovie("sound.swf");
	} else if (chosen == "sound2") {
		container.loadMovie("sound2.swf");
	} else if (chosen == "sound3") {
		container.loadMovie("sound3.swf");
	}
}

But, someone shouldn’t happen to know how to set the text color to black in the dropdown part, and after selected and item?? Because I have made the highlight area white (alpha 0%) and then you cant see the white text.

what do you mean? the text only has to be black when dropping down or after selected it? or does it has to be black all the time?

Black all the time, when dropped down, when selected etc…

have you searched the kirupaforums already :wink: http://www.kirupaforum.com/forums/showthread.php?t=64076&highlight=combobox

I have tried using style stuff, but the text still gets white after I have selected it, I dont want the gray highlight, so I made it alpha 0, but the text is still white after using style stuff

then you haven’t tried good enough :wink:


formStyleFormat = new FStyleFormat();
formStyleFormat.textColor = "0x000000";
formStyleFormat.textSelected = "0x000000";
formStyleFormat.textFont = "Arial";
formStyleFormat.addListener(comboBox);

.textSelected is form the text you selected en when its dropped down