Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Extendscript. Assign a function to a button

  • Extendscript. Assign a function to a button

    Posted by Hamid Rohi-bilverdy on June 10, 2015 at 2:22 pm

    Hi

    Sorry if this is the wrong forum to post the question.

    I have followed the extendscript tutorial series from David Torno. Really Great stuff.

    I have manged to follow along and build the dockable GUI.

    Here is the code:

    // COMPLET BASE FOR MENU DOCKABLE
    function myScript ( thisObj) {
    function myScript_buildUI(thisObj ) {
    var my panel = (thisObj instanceof Panel) ? thisObj: new Window("palette", "My GUI" undefined, {resizeable: true});
    res = "group {orientation: 'row',\
    groupOne: Group{orientation: 'column',\
    minButton: Button{text: 'btn1'},\
    minButton2: Button{text: 'btn2'},\
    }";

    myPanel.grp = myPanel.add (res),
    }
    var myScriptPal = myScript_buildUI(thisObj);
    If ( (myScriptPal !=null) && (myScriptPal instanceof Window){
    myScriptPal.center();
    myScriptPal.show ();
    }
    }
    myScript(this);

    A simpel menu with a group of 2 buttons in a single column.

    I can’t figure out how to assign or associate an action when one clicks on the buttons.

    Say when one click button2 and I wanted that a new comp were to be created:


    var newComp= app.project.items.addComp("myNewComp",1920,1080,1.0,10,25);

    How do I assign that code to one of the buttons??

    Cheers
    /HRB

    Andres Selgoja replied 10 years, 9 months ago 2 Members · 1 Reply
  • 1 Reply
  • Andres Selgoja

    July 23, 2015 at 11:00 am

    Hi

    It should work like this:

    minButton2.onClick = function () {
    var newComp= app.project.items.addComp("myNewComp",1920,1080,1.0,10,25);
    }

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy