-
set a function to call up a certain code based on a user dropdown choice
HI,
I am building a tool that will apply a set of effects to the selected layer. The effects parameters will change based on a drop-down UI element chosen by the user. What is the best way to implement the function? Currently, I am using an if/else if to call different settings to be applied to each layer, but that isn’t working.
win=new Window("palette","FluentShadowUI",[0,0,200,100],{resizeable:true,independent:false,minimizeButton:false,maximizeButton:false,resizeable:false,});
but_1=win.add("button",[20,60,120,80],"Fluent Shadow");
but_1.helpTip="Select a layer";
pixel_size=win.add("dropdownlist",[20,20,120,42] ,["1px","2px","3px","4px","6px","8px","9px","12px","16px","24px","32px","48px","64px","80px","96px",""]);
pixel_size.helpTip="Choose your Shadow size";
win.center();
win.show();but_1.onClick = function(){
if(pixel_size = "1px"){
var effectsGroup = app.project.activeItem.selectedLayers[0];
myEffect1px = effectsGroup.Effects.addProperty("ADBE Drop Shadow");
effectsGroup.property("ADBE Effect Parade").property(1).property("ADBE Drop Shadow-0002").setValue(5.1);
effectsGroup.property("ADBE Effect Parade").property(1).property("ADBE Drop Shadow-0003").setValue(180);
effectsGroup.property("ADBE Effect Parade").property(1).property("ADBE Drop Shadow-0004").setValue(1);
effectsGroup.property("ADBE Effect Parade").property(1).property("ADBE Drop Shadow-0005").setValue(4);
myEffect1px = effectsGroup.Effects.addProperty("ADBE Drop Shadow");
effectsGroup.property("ADBE Effect Parade").property(2).property("ADBE Drop Shadow-0002").setValue(15.3);
effectsGroup.property("ADBE Effect Parade").property(2).property("ADBE Drop Shadow-0003").setValue(180);
effectsGroup.property("ADBE Effect Parade").property(2).property("ADBE Drop Shadow-0004").setValue(1);
effectsGroup.property("ADBE Effect Parade").property(2).property("ADBE Drop Shadow-0005").setValue(4);
myEffect1px = effectsGroup.Effects.addProperty("ADBE Drop Shadow");
effectsGroup.property("ADBE Effect Parade").property(3).property("ADBE Drop Shadow-0002").setValue(15.3);
effectsGroup.property("ADBE Effect Parade").property(3).property("ADBE Drop Shadow-0003").setValue(180);
effectsGroup.property("ADBE Effect Parade").property(3).property("ADBE Drop Shadow-0004").setValue(0.5);
effectsGroup.property("ADBE Effect Parade").property(3).property("ADBE Drop Shadow-0005").setValue(4);
}else if(pixel_size = "2px"){
myEffect2px = effectsGroup.Effects.addProperty("ADBE Drop Shadow");
myEffect2px.property("ADBE Effect Parade").property(1).property("ADBE Drop Shadow-0002").setValue(5.1);
myEffect2px.property("ADBE Effect Parade").property(1).property("ADBE Drop Shadow-0003").setValue(180);
myEffect2px.property("ADBE Effect Parade").property(1).property("ADBE Drop Shadow-0004").setValue(2);
myEffect2px.property("ADBE Effect Parade").property(1).property("ADBE Drop Shadow-0005").setValue(6);
myEffect2px = effectsGroup.Effects.addProperty("ADBE Drop Shadow");
myEffect2px.property("ADBE Effect Parade").property(2).property("ADBE Drop Shadow-0002").setValue(15.3);
myEffect2px.property("ADBE Effect Parade").property(2).property("ADBE Drop Shadow-0003").setValue(180);
myEffect2px.property("ADBE Effect Parade").property(2).property("ADBE Drop Shadow-0004").setValue(2);
myEffect2px.property("ADBE Effect Parade").property(2).property("ADBE Drop Shadow-0005").setValue(6);
myEffect2px = effectsGroup.Effects.addProperty("ADBE Drop Shadow");
myEffect2px.property("ADBE Effect Parade").property(2).property("ADBE Drop Shadow-0002").setValue(15.3);
myEffect2px.property("ADBE Effect Parade").property(2).property("ADBE Drop Shadow-0003").setValue(180);
myEffect2px.property("ADBE Effect Parade").property(2).property("ADBE Drop Shadow-0004").setValue(2);
myEffect2px.property("ADBE Effect Parade").property(2).property("ADBE Drop Shadow-0005").setValue(6);}else if(pixel_size = "3px"){
myEffect3px = effectsGroup.Effects.addProperty("ADBE Drop Shadow");
myEffect3px.property("ADBE Effect Parade").property(1).property("ADBE Drop Shadow-0002").setValue(5.1);
myEffect3px.property("ADBE Effect Parade").property(1).property("ADBE Drop Shadow-0003").setValue(180);
myEffect3px.property("ADBE Effect Parade").property(1).property("ADBE Drop Shadow-0004").setValue(2);
myEffect3px.property("ADBE Effect Parade").property(1).property("ADBE Drop Shadow-0005").setValue(6);
myEffect3px = effectsGroup.Effects.addProperty("ADBE Drop Shadow");
myEffect3px.property("ADBE Effect Parade").property(2).property("ADBE Drop Shadow-0002").setValue(15.3);
myEffect3px.property("ADBE Effect Parade").property(2).property("ADBE Drop Shadow-0003").setValue(180);
myEffect3px.property("ADBE Effect Parade").property(2).property("ADBE Drop Shadow-0004").setValue(2);
myEffect3px.property("ADBE Effect Parade").property(2).property("ADBE Drop Shadow-0005").setValue(6);
myEffect3px = effectsGroup.Effects.addProperty("ADBE Drop Shadow");
myEffect3px.property("ADBE Effect Parade").property(2).property("ADBE Drop Shadow-0002").setValue(15.3);
myEffect3px.property("ADBE Effect Parade").property(2).property("ADBE Drop Shadow-0003").setValue(180);
myEffect3px.property("ADBE Effect Parade").property(2).property("ADBE Drop Shadow-0004").setValue(2);
myEffect3px.property("ADBE Effect Parade").property(2).property("ADBE Drop Shadow-0005").setValue(6);}...
}