I had a similar issue. In my project, the CB had values ranging from
1-27, and the objects on stage had corresponding identifiers. So this
solution worked:
//CODE
//-------------------------------------
//let's say my objects are identified as item1, item2, item3...
var cbListener:Object = new Object();
cbListener.itemRollOver = function(evt_obj:Object) {
val = (1+evt_obj.index);
//highlight or do something with ["item"+val];
this["item"+val]._alpha = 40;
};
//add listener
myCB.addEventListener("itemRollOver", cbListener);
//END CODE
//------------------------------------------------------------
See if that works
-Sean
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
[EMAIL PROTECTED]
Sent: Friday, June 16, 2006 3:38 AM
To: [email protected]
Subject: [Flashcoders] Select combobox item by data value
Hello everyone. I am trying to select an item in a combobox component
based on
its data value. I found this solution (which works) but I have multiple
comboboxes placed in many different spots in my movie that need this
same
functionality. Can anyone suggest a way to reuse this for multiple
comboboxes
or possibly a better solution altogether? cheers!
CODE:::
function selectByData(selData:String):Number {
var index:Number = -1;
for (var i = 0; i<=ambient_temp_cb.length; i++) {
if (ambient_temp_cb.getItemAt(i).data eq selData) {
index = i;
break;
}
}
return index;
}
ambient_temp_cb.selectedIndex = selectByData(
_root.Environment.ambient_temp_units );
Mike
_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com
_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com