If the subject isn’t entirely clear, it’s because I’m not sure how to describe what I want to do. What I have currently is a large group of ComboBox components which trigger an event handler, which uses a Switch…Case statement to determine the selection, and then uses another Switch…Case to figure out which ComboBox actually called it so the function called can use the appropriate arguments. The way I have it written has bloated the code, so I’m wondering if there’s a shorter way to do this.
function change(evt) {
num = evt.target.selectedItem.data;
switch (num) {
case "ltgold" :
row_style_for_menu = 'ltgold';
switch (evt.target) {
case stylemenu1 :
set_row_style('1', row_style_for_menu);
menu_index_1 = 0;
trace('one');
break;
case stylemenu2 :
set_row_style('2', row_style_for_menu);
menu_index_2 = 0;
trace('two');
break;
case stylemenu3 :
set_row_style('3', row_style_for_menu);
menu_index_3 = 0;
trace('three');
break;
}
break;
case "dkgold" :
row_style_for_menu = 'dkgold';
switch (evt.target) {
case stylemenu1 :
set_row_style('1', row_style_for_menu);
menu_index_1 = 1;
trace('one');
break;
case stylemenu2 :
set_row_style('2', row_style_for_menu);
menu_index_2 = 1;
trace('two');
break;
case stylemenu3 :
set_row_style('3', row_style_for_menu);
menu_index_3 = 1;
trace('three');
break;
}
break;
case "ltred" :
row_style_for_menu = 'ltred';
switch (evt.target) {
case stylemenu1 :
set_row_style('1', row_style_for_menu);
menu_index_1 = 2;
trace('one');
break;
case stylemenu2 :
set_row_style('2', row_style_for_menu);
menu_index_2 = 2;
trace('two');
break;
case stylemenu3 :
set_row_style('3', row_style_for_menu);
menu_index_3 = 2;
trace('three');
break;
}
break;
}
}