Copy link to clipboard
Copied
Ok, so I am making a script that creates a handheld camera. I want to make it where the user can choose between two different cameras. (one shakes more than the other) I am doing this via a dropdownlist, but I can't get it to work. Did I mention I am new to this?
Here's the peice of the code.....
ddList = new Array("Camera 1", "Camera 2");
dropdownlistOne = myPanel.add("dropdownlist", [21,134,126,159], ddList);
if(dropdownlistOne.selection ==0){
buttonOne.onClick = makeCam;
}else{
buttonOne.onClick = makeCam2;
}
Any ideas? Thanks in advance.
-Tyler
It's difficult to be specific without having the whole code to test, but generally I'd suggest you just have one onClick function, then when that is called, check the pulldown selection from inside that function. So something like:
buttonOne.onClick = onButtonOneClick;
function onButtonOneClick() {
if (myPalette.dropdownlistOne.selection.index == 0) {
// do this
} else {
// do this instead
}
}
But depending on the rest of your code, it may just be that you're checking d
...Copy link to clipboard
Copied
It's difficult to be specific without having the whole code to test, but generally I'd suggest you just have one onClick function, then when that is called, check the pulldown selection from inside that function. So something like:
buttonOne.onClick = onButtonOneClick;
function onButtonOneClick() {
if (myPalette.dropdownlistOne.selection.index == 0) {
// do this
} else {
// do this instead
}
}
But depending on the rest of your code, it may just be that you're checking dropdown.selection when maybe you should be checking dropdown.selection.index.
Copy link to clipboard
Copied
YES! Thanks Paul!