all groups > flash actionscript > november 2007 >
You're in the

flash actionscript

group:

Combo Box Component


Re: Combo Box Component dan mode smith ~Adobe Community Expert~
11/2/2007 2:13:27 PM
flash actionscript: [quoted text, click to view]

trace("Selected Item Data: "+my_cb.selectedItem.data);
trace("Selected Item Label: "+my_cb.selectedItem.label);

hth


--
Dan Smith > adobe community expert
http://www.dsmith.tv

Re: Combo Box Component dan mode smith ~Adobe Community Expert~
11/2/2007 4:09:18 PM
[quoted text, click to view]

Did you put the code I supplied in the event handler?

var listenerObject:Object = new Object();
listenerObject.change = function(evtObj:Object) {
// code placed here executes
// when the event is triggered
trace("Selected Item Data: "+my_cb.selectedItem.data); //Put code here
};

--
Dan Smith > adobe community expert
http://www.dsmith.tv

Combo Box Component fermp
11/2/2007 7:59:30 PM
Hi all,

I am trying to figure out how to put a comboBox in my Flash form and normally
I just use something like:

countryList.dataProvider = ["Country1", "Country2", "Country3", "Country4"];

var listenerObject:Object = new Object();
listenerObject.change = function(evtObj:Object) {
// code placed here executes
// when the event is triggered
trace("Selected Item: "+countryList.selectedItem);
};
countryList.addEventListener("change",listenerObject);

This will give me the selected item's value which I can chuck in a variable
and send off to my form...

Well that is usually good enough but now I want to have a Label AND a Value so
that when the user does the drop down they see the Label but I am actually
sending the Value. I am messing around with the Flash Help code and I kind of
see how this is working yet I can not get at the data I need which is the Value
not the Label.

my_cb.dataProvider = [{name:"Gary", gender:"male"}, {name:"Susan",
gender:"female"}];
my_cb.labelField = "name";

var listenerObject:Object = new Object();
listenerObject.change = function(evtObj:Object) {
// code placed here executes
// when the event is triggered
trace("Selected Item: "+my_cb.selectedItem);
};
my_cb.addEventListener("change",listenerObject);

Any help on this would be greatly appreciated.
Re: Combo Box Component fermp
11/2/2007 9:41:49 PM
Hi Dan,

When I use this code I get:

Selected Item Data: undefined
Selected Item Label: undefined

You would think there was something easy to allow for a label being different
from the variable I'm sending. All I want to do is make the drop down menu say
"Afghanistan" while I am sending the form data "AF" to the .php script that
will save the data to a mySQl database. I can easily send the name of the
country (Afghanistan) as thats the name of my_cb.selectedItem. I'm just not
sure why it is so difficult to send the value (AF) instead. I'm just not
getting it.
AddThis Social Bookmark Button