Change handler?

I am still having tons of trouble here with this. I have a listbox, whenever something is selected in the list box, i need it to advance to a corresponding frame. I have an example that I will attach, this is as far as I have gotten, but I am still missing something very simple. Here is my as:


function dropdown_check() {
}
if (dropdown.getValue() == 2) {
	gotoAndStop(2);
} else if (dropdown.getValue() == 3) {
	gotoAndStop(2);
} else if (dropdown.getValue() == 4) {
	gotoAndStop(4);
} else if (dropdown.getValue() == 1) {
	gotoAndStop(1);
}

In the change handler field of the parameters box, I have
[AS]dropdown_check[/AS]

It still won’t work. I am sure this is not an emergency to anyone but me, but I have been wrestling with this for days! Thanks in advance for the help,
nat

Ok, I didn’t test anything, but I can’t tell you something right off the bat…

[AS]function dropdown_check() {
}
if (dropdown.getValue() == 2) {
gotoAndStop(2);
} else if (dropdown.getValue() == 3) {
gotoAndStop(2);
} else if (dropdown.getValue() == 4) {
gotoAndStop(4);
} else if (dropdown.getValue() == 1) {
gotoAndStop(1);
}[/AS]

Look at how you defined your function.

You used [AS]function dropdown_check() {
}[/AS] which is correct, but then you defined all your contents of your functions AFTER that. You are supposed to defined all your content inside the {} of the function. So it would be…

[AS]function dropdown_check() {
if (dropdown.getValue() == 2) {
gotoAndStop(2);
} else if (dropdown.getValue() == 3) {
gotoAndStop(2);
} else if (dropdown.getValue() == 4) {
gotoAndStop(4);
} else if (dropdown.getValue() == 1) {
gotoAndStop(1);
}
}[/AS]

But aside from that, I can also make this easier for you to save on if statements…

[AS]function dropdown_check() {
gotoAndStop(dropDown.getValue());
}[/AS]

This will gotoAndStop at whatever frame the value of the dropDown is at :slight_smile:

Beautiful! Thanks, it finally works! I knew it was something small. I have one more question on the IF statement thing, if I wanted real words, lets say colors in stead of numbers, there wouldn’t be a way to do that using your simplified lF statement?

Also, on the component parameters, what is the difference between Labels and Data? What is the # in the left column on Labels saying?
Thank you for your help, you don’t need to bother with this reply, but if someone else knows I would appreciate the clarification.
Thanks!
nathan

The labels is the text labels that the viewer is able to see. You can set all those to the colors and the getValue() method will still work. You click on the plus sign to add a new label to the listbox (drop box, or whatever) then you change the text to your own. This adds an item with the new label.

As for Data… I have no clue honestly. I never use components, so I never bothered to learn how they work.