Animate Pro: Scripting tutorial

As most of you are aware I recently did a scripting tutorial on my youtube channel. If you weren’t you can go find it there. Below is the code from the tutorial if you can’t be bothered typing or something isn’t clear on the screen.

function tutorialAddTH()
{

//add interface
d = new Dialog;
d.title = “Options”;

var bothRB = new RadioButton;
var toneRB = new RadioButton;
var highlightRB = new RadioButton;

bothRB.checked = true;
bothRB.text = “Highlight and Tone”;
toneRB.checked = false;
toneRB.text = “Tone”;
highlightRB.checked = false;
highlightRB.text = “Highlight”;

var group = new GroupBox;
group.add(bothRB);
group.add(toneRB);
group.add(highlightRB);
d.add(group);
d.addSpace(1);


var CompositeRB = new RadioButton;
var NoCompositeRB = new RadioButton;

NoCompositeRB.checked = true;
NoCompositeRB.text = “Don’t connect to composite”;
CompositeRB.checked = false;
CompositeRB.text = “Connect to composite”;

var group = new GroupBox;
group.add(CompositeRB);
group.add(NoCompositeRB);
d.add(group);
d.addSpace(1);

var prefix = new LineEdit;
prefix.label = “prefix”;
prefix.text = “”;
d.add(prefix);



rc = d.exec();

if(!rc)
{
// Call dialog, pressing “Cancel” returns false
return;
}

if((bothRB.checked == true) || (toneRB.checked == true))
{

var elemname = prefix.text + “ToneMatte”;
var elemId = element.add(elemname, “BW”, scene.numberOfUnitsZ(), “SCAN”, “TVG”);
var vnode = node.add(node.root(), elemname, “READ”, -80, -320, 0);
column.add(elemname, “DRAWING”);
column.setElementIdOfDrawing(elemname, elemId );
node.linkAttr(vnode, “DRAWING.ELEMENT”, elemname);

node.add(node.root(),prefix.text + “Tone”,“TONE”,15,-280,0);

node.link(“Top/” + prefix.text + “ToneMatte”,0,“Top/” + prefix.text + “Tone”,1);

}

if((bothRB.checked == true) || (highlightRB.checked == true))
{

var elemname = prefix.text + “HighlightMatte”;
var elemId = element.add(elemname, “BW”, scene.numberOfUnitsZ(), “SCAN”, “TVG”);
var vnode = node.add(node.root(), elemname, “READ”, -80, -240, 0);
column.add(elemname, “DRAWING”);
column.setElementIdOfDrawing(elemname, elemId );
node.linkAttr(vnode, “DRAWING.ELEMENT”, elemname);

node.add(node.root(), prefix.text + “Highlight”,“HIGHLIGHT”,15,-200,0);

node.link(“Top/” + prefix.text +“HighlightMatte”,0,“Top/” + prefix.text + “Highlight”,1);

}

if(bothRB.checked == true)
{

node.link(“Top/” + prefix.text + “Tone”,0,“Top/” + prefix.text + “Highlight”,0);

}

if((CompositeRB.checked == true) && (toneRB.checked == false))
{

node.link(“Top/” + prefix.text + “Highlight”,0,“Top/Composite”,0);

}
else if(toneRB.checked == true)
{
node.link(“Top/” + prefix.text + “Tone”,0,“Top/Composite”,0);

}

}