PDA

View Full Version : Put parameters in a function called by the "change" event of a combobox


emilie_t
07-05-2007, 10:01 PM
Hello everyone,

As the title of my post might be a little hard to catch, let me explain a bit more...

I've got several combobox.
When changing their value, each of them launch the same action, except that they do it on different clips.

Let' say
list1_cb will work on clipA_mc
list2_cb on clipB_mc
list3_cb on clipC_mc
...

instead of doing
list1_cb.addEventListener("change", function1);
list2_cb.addEventListener("change", function2);
list3_cb.addEventListener("change", function3);
...
and than create a function function1, function2, function3 which would be the same, except acting on different clips

I would rather do
list1_cb.addEventListener("change", common_function(clipA_mc));
list2_cb.addEventListener("change", common_function(clipB_mc));
liste3_cb.addEventListener("change", common_function(clipC_mc));

and then, only define a function common_function which would work on a movieclip known as a parameter.

Unofrtunately, it looks like it's not possible to put any parameter to a function called by the "change" event on a combobox.

Would anybody have an idea about how I can do that ?

Thanks a lot to all of you who read this and tried to help me

Emilie

panel
07-05-2007, 10:57 PM
this is a litte diffrent way of thinking, but it should be all you need. You can set one function fired after change event and then use event.target property in this function.
event_obj.target.selectedItem.label

emilie_t
07-05-2007, 11:09 PM
I'll try that...
Thanks a lot

Emilie

this is a litte diffrent way of thinking, but it should be all you need. You can set one function fired after change event and then use event.target property in this function.
event_obj.target.selectedItem.label