all groups > flash actionscript > october 2006 >
You're in the

flash actionscript

group:

Combo Box Help


Combo Box Help Dave.Hollings
10/18/2006 11:52:42 PM
flash actionscript: Hi all,

This might be a simple one however I just can't figure out why it is not
working. I have a combo box on my stage and and send_btn.

I have added a trace on a variable which I am trying to store the label the
user selects in the combo box. I have the following code

Listener:

// event listener & handler function
var cbListenerbject = new Object();
cbListener.change = function(evt_obj):Void {
var currentlySelectedobject = evt_obj.target.selectedItem;
var topic = currentlySelected.label_;
};

Send function:
this.send_btn.onRelease = function()
{
trace(topic)
};

Can someone please help with this, thanks in advance

Re: Combo Box Help kglad
10/19/2006 1:16:46 AM
you have several errors, each of which would cause the failure.

1. you have not associated the listener with your combobox
2. there's typo in your 2nd line of code
3. topic is local to your listener. ie, you prefixed with var
4. currentlySelected is not the same as currentlySelectedobject
5. label_ should be label.

try:



// event listener & handler function
var cbListener:Object = new Object();
cbListener.change = function(evt_obj):Void {
var currentlySelectedobject = evt_obj.target.selectedItem;
topic = currentlySelectedobject.label;
};
this.send_btn.onRelease = function() {
trace(topic);
};
cb.addEventListener("change", cbListener); // <-- where cb is your
combobox'es instance name
Re: Combo Box Help Dave.Hollings
10/19/2006 3:15:41 PM
kglad,

Many thanks for having a look at my post, your corrections worked and made sense. This is why I like these forums everyone can help everyone.

Re: Combo Box Help kglad
10/19/2006 3:43:55 PM
AddThis Social Bookmark Button