Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Combobox onrelease (??) Function

Status
Not open for further replies.

caffrinho

MIS
Mar 1, 2002
91
GB
Please help,

have created a form in flash MX that contains a number of comboboxes. I populate these boxes by loading values from mySQL via PHP. So far so good...

my problem is in finding the correct event to run some code after a selection has been made.

currently i am using the onrelease function to populate a dynamic text field with the index of the selected item. (until i can figure out exactly what i'm going to do with the selected values!!)

selTeam_mc.cboPl_gk.onRelease = function() {
var plval;
plval = selTeam_mc.cboPl_gk.getselectedindex();
selTeam_mc.temp_txt.text = plval;
};

The only problem is, i click on the combobox to open the list, (the field updates with the last selected item), when you then select a new item, this doesn't update the field. (At the moment the value in the temporary text field lags behind the value selected in the combobox)

So i guess the question i am asking is; what event can i use for my combobox that will update my field as soon as an item is selected?

I hope you can understand my ramblings,

C

 
What about having the onRelease call an event that waits 1/4 of a seond and then checks the value of the combo box, would that work?
-ben
 
Thanks Ben, I'm sure that would work for a small list and it's better than anything i've come up with.

My problem, however, is with with a list that may contain up to 200 entries. This would mean that there would be an indeterminate amount of time elapsed between clicking the combobox and making the selection.

 
I've found a workaround...
Unless somebody can point me in the direction of a better resolution, i have found that i can use OnKillFocus to run the script required. Not my ideal solution, but it works.

Thanks

C
 
What you need to do is create a function to handle change event that will reassign the variable on the _root as soon as the change occurs. The following is for an MX Pro component (player 7, AS 2). If you are using an older version of flash there is a slightly different way to handle it.

Code:
myListener = new Object();
myListener.change = function(component) {
	varName = component.target.value;
	_root.newVar = varName;
};

yourCombo.addEventListener("change", myListener);

If you have a dynamic text box in any timline assigned to the variable "_root.newVar" and a combo box component called yourCombo the script above will change the value of the variable instantly everytime the combo box is changed.

Hope it helps!

Wow JT that almost looked like you knew what you were doing!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top