I need to know how to use the combobox component to be able to control the timeline. I have very little knowledge of actionscript, so the more help, the better. I have looked for tutorials on the internet, but I still have found none.
you can make the comboBox affect virtualy anything onstage depending on what is selected. Can you be more specific as to what you want done when what happens, and i'll be happy to help you..
well, i want the combobox to go to different frames depending on the word clicked on. i'm assuming that i have to use "goto" at some point to get this effect, but i don't know. i hope that's enough information. thanks for the help, i really appreciate it.
you will first need to populate the comboBox
this can be done thru the proeprty inspector, but i prefer to do it by script. It's just easier for me to read it that way..This script should be on the main timeline, in the frame where the combobox appears
as you can see, adding by script is very easy. The tag that says "label" is what is actually visible in the combobox to the user. They never see the "data" part, which can be anythign you want for the purpose of scripting.. In your case, the "data" for each one will probably be a frame label name that you want each one to go to..
the last line of script, _root.comboBox.sortItemsBy, this will sort the list by label, alphabetically. the ASC simply means to sort in ascending order. You can also use DESC if you want to sort descending, or you dont have to sort at all, you can just add the items in the order you want them to appear...
lemme know when you have this completed, and we'll move on. My goal is to help you understand what you're doing, not just copy and paste, so lets take it a step at a time
let's add a blank selection to your combobox so that nothing is selected by default
add this to the top of your list:
code:
_root.comboBox.addItem("","");
this will need to be the first. A blank is not affected by sorting order.
next,we'll need to set a change handler for the combobox. A change handler is just as it sounds.. a function that is called everytime the selected item is changed in your combobbox...
the change handler is set as follows:
code:
_root.comboBox.setChangeHandler("functionName");
we'll define the function in a minute...
go ahead and make your select button as well. Let me know if you're using a component button or making your own.
okey dokey, now for the fun part.
we'll create our change handler funtion.
we'll also need to create a variable to hold the information we'll pull from our change handler function:
code:
var choice1;
//this simply creates a variable named
//choice1
function cbUpdate() {
_root.choice1 = _root.cmoboBox.getSelectedItem().data;
}
pretty straightforward, this will simply look at the item that is currently selected in the combobox, and extract its "data", sending it to the variable we've named choice1.
now for the button, give it an instance name if you havent done that yet..
back on the main timeline, we'll make our button do something when pressed/released
see what we did? If you used your frame labels as your data for each selection, then when the button is pressed it will go to the approriate frame label.
This can easily be altered to work several different ways.
here's a more in-depth one i made for work to help hotline reps to pull up parts lists. It uses radio buttons to make a few choices. The user choice determines how the combo boxes are populated, and finally pulls up the desired parts list.. Check out the script.
looks okay on first glance. Are your items loading into the combobox?
Let's add a trace to the change handler function to see if the information is getting passed properly:
when the movie is tested, each time you chagne your choice, an output window showing your current selection.. If this doesnt work, please attach your FLA and i'll take a look-see..