-
Change numbers in script depending on number in an effect
I have worked with a script for a while and the only thing I would want to add before I go public with it is an connection between an effect and the script. I have no idea if it’s even possible to do. I have searched around without any success of finding an answer.
In my script I have a button that adds Linear Wipe to the selected layer. I then have a slider and an EditText-box blinded to each other and the Transition Completion on the Linear Wipe, so when I slide the slider both the numbers in the EditText-box and the percentage in Linear Wipe changes to the same number. The same if I change in the EditText-box. The final thing I would want to do is for it to work the same if I slide the Transition Completion in the Linear Wipe effect.
This is what I have in my script so far:
my_palette.grp.optsRow.text_input.onChanging = on_textInput_changed;
my_palette.grp.optsRow.mySlider.onChanging = mySlider_changed;
my_palette.grp.strt.startButton.onClick = onStartClick; //Liniar Wipe button on clickfunction onStartClick () //When clicking on Linear Wipe button
{
var activeItem = app.project.activeItem;
if (activeItem == null || (activeItem instanceof CompItem) == false) {
alert("Please select a composition in the timeline.", scriptName);
} else {
var selectedLayer = activeItem.selectedLayers[0]; //Selected Layer
if (selectedLayer == null || (selectedLayer.source instanceof CompItem) == false) {
alert("Please select a composition in the timeline.", scriptName);
} else
app.beginUndoGroup("Add Linar Wipe");
selectedLayer.Effects.addProperty("ADBE Linear Wipe");
transitionLW = selectedLayer.property("ADBE Effect Parade").property("ADBE Linear Wipe");
transitionLW.property("ADBE Linear Wipe-0001").setValue(my_palette.grp.optsRow.mySlider.value);
var LW_change = transitionLW.property("ADBE Linear Wipe-0001");
app.stopUndoGroup();}
}//
// This function is called when the user enters text for the scale.
//
function on_textInput_changed()
{
// Set the scale_factor based on the text.
var value = this.text;
if (isNaN(value)) {
alert(value + " is not a number. Please enter a number. (If the number contain '','' please change to a ''.''", scriptName);
} else {
scale_factor = value/100;
my_palette.grp.optsRow.mySlider.value = Math.round(value);
transitionLW.property("ADBE Linear Wipe-0001").setValue(value);
}
}//
// This function is called when the user slides the scale.
//
function mySlider_changed()
{
// Set the scale_factor based on the text.
var value = this.value;
if (isNaN(value)) {
alert(value + " is not a number. Please enter a number.", scriptName);
} else {
scale_factor = value/100;
my_palette.grp.optsRow.text_input.text = Math.round(value);
transitionLW.property("ADBE Linear Wipe-0001").setValue(value);
}
}