Retrieving user entered value?
Posted: February 14th, 2009, 6:30 pm
I am running some experiments and teaching myself AE Dockable ScriptUI building (yes, I know my first script was a dockable panel, but only with Paul's help.
) and I can't seem to find the answer/syntax for retrieving a user entered value from an edittext box within the AE script language. I created my text box like this...
I set 5 as a default, but the user can change it to say 100 or whatever.
The full script is here: (I used Lloyd Alvarez's duplicate layer script from the AENY video as a test and built the UI via Ian Haigh's Ease & Whiz script style cause it made more sense to me)
You can also see that right now there is one line (line 42 if you want to count) set like this:
The script works and duplicates the layer 10 times with this set value, but I want to plug in the user entered data.

Code: Select all
myPanel.butTwo = myPanel.add("editText", [45, 10, 100, 30], "5");
The full script is here: (I used Lloyd Alvarez's duplicate layer script from the AENY video as a test and built the UI via Ian Haigh's Ease & Whiz script style cause it made more sense to me)
Code: Select all
function Dup_buildUI(thisObj) {
var myPanel = (thisObj instanceof Panel) ? thisObj : new Window("palette", "Duplicator", [100, 100, 300, 300]);
//Jeff Almasol's solution to fix text color
var winGfx = myPanel.graphics;
var darkColorBrush = winGfx.newPen(winGfx.BrushType.SOLID_COLOR, [0,0,0], 1);
//notes------------------------------------[10, 10, 40, 30] = [LeftEdge, TopEdge, ButtonEdge, ButonEdge]
//"Qty:" text
myPanel.butOne = myPanel.add("staticText", [10, 10, 40, 30], "Qty:");
//Input box
myPanel.butTwo = myPanel.add("editText", [45, 10, 100, 30], "5");
myPanel.butTwo.graphics.foregroundColor = darkColorBrush; //Keeps text black at all times
//"Do It!" button
myPanel.butThree = myPanel.add("button", [10, 40, 70, 60], "Dup It!");
myPanel.butThree.onClick = dupIt; //launch "dupIt" function when button is clicked
return myPanel;
}
function dupIt()
{
app.beginUndoGroup("Dup It!")
var myComp = app.project.activeItem;
if(myComp instanceof CompItem) {
//Selected layers loop
var myLayers = myComp.selectedLayers;
for (var i = 0; i < myLayers.length; i++) {
var myLayer = myLayers[i]
var selLayers = myLayer;
var numCopies = 10;
var counter = 0;
app.beginUndoGroup("Dup It!")
while(counter < numCopies){
selLayers.duplicate();
counter++
app.endUndoGroup()
}
}
}
}
Dup_buildUI(this);
Code: Select all
var numCopies = 10;