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
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
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.
Don't see what you're looking for? Try a search.
|