Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 06-05-2003, 09:22 AM   #1
Mortimer Jazz
Thing
 
Mortimer Jazz's Avatar
 
Join Date: Jun 2001
Location: UK
Posts: 2,418
Default ComboBox - useful info

Some info on using the ComboBox. Hope this proves useful.

If you've used the ComboBox before, you may have encountered a problem. When you run your movie, your ComboBox may display a label value, but the corresponding data value isn't assigned (ie The specified Change Handler doesn't execute at run time), or conversely, your change handler does execute on run time, but you don't want it to.

This depends on whether your change handler uses a normal function (function myFunc(){//code}) or a function literal (myFunc = function(){//code})

Function literals are best used if you don't want the Change Handler to execute when the movie is run. For example:
ActionScript Code:
main = new Array(); main.push({label:"John", data:"Dancer" }); main.push({label:"Jack", data:"Artist" }); main.push({label:"Julie", data:"Friend" }); main.sortOn("label"); main.unshift({label:"Select one", data:"default" });//set default value myComboBox.setDataProvider(main); onSubmit = function(){     if(myComboBox.getValue()!= "default"){         trace(myComboBox.getValue());     } /*other code that you may want to run (even if "Select one" is chosen) - but not upon inital loading*/ }

Whilst standard functions are best used if you do want the Change Handler to be run according to the default value of the ComboBox
ActionScript Code:
main = new Array(); main.push({label:"John", data:"Dancer" }); main.push({label:"Jack", data:"Artist" }); main.push({label:"Julie", data:"Friend" }); main.sortOn("label"); myComboBox.setDataProvider(main); function onSubmit(){     trace(myComboBox.getValue()); }


For more info on using named arrays in this manor check out the excellent power of arrays III tutorial
Mortimer Jazz is offline   Reply With Quote
Old 06-05-2003, 01:17 PM   #2
farafiro
Addicted To FLASH
 
farafiro's Avatar
 
Join Date: Dec 2001
Location: Egyptian in UAE
Posts: 12,436
Send a message via MSN to farafiro Send a message via Yahoo to farafiro
Default

__________________
‚€* GOD Is Near ‚€*
Questions Don't PM for Questions . Thanks
An eye for an eye, make the whole world blind
_____________________________________________GHANDI
farafiro is offline   Reply With Quote
Old 07-08-2003, 09:00 PM   #3
ScratUAD
Registered User
 
Join Date: Jun 2002
Location: Canada
Posts: 99
Default

this may make me sound like an idiot... but I've been trying to qonquer that combo box for months now... and your scripting did it! Thank you so very much for taking that brief moment to post it!

Thank you!
ScratUAD is offline   Reply With Quote
Old 07-08-2003, 11:34 PM   #4
Mortimer Jazz
Thing
 
Mortimer Jazz's Avatar
 
Join Date: Jun 2001
Location: UK
Posts: 2,418
Default

Mortimer Jazz is offline   Reply With Quote
Old 07-09-2003, 12:35 AM   #5
freddycodes
Master of Nothing
 
Join Date: Dec 2002
Location: San Diego, CA
Posts: 2,468
Default

Of course one could also achieve this effect by dynamically assigning the changeHandler after the data is loaded.
ActionScript Code:
main = new Array(); main.push({label:"John", data:"Dancer" }); main.push({label:"Jack", data:"Artist" }); main.push({label:"Julie", data:"Friend" }); main.sortOn("label"); myComboBox.setDataProvider(main); myComboBox.setChangeHandler("onSubmit"); function onSubmit(){         trace(myComboBox.getValue()); }
freddycodes is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump


All times are GMT. The time now is 11:17 PM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.