Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Variables returning as Undefined – ExtendScript

  • Variables returning as Undefined – ExtendScript

    Posted by Ronan De lacy on November 19, 2020 at 6:36 am

    Hello all,

    Wondering if anyone can point out where I’ve gone wrong here. I’m trying to build a basic script that contains a dropdown list, EditText box and a button.

    Everything below is working, apart from my width and height inputs which are returning as “Undefined”.

    Thanks in advance,

    Ronan

    pal.grp.groupOne.createNewProjectButton.onClick = function ()
    {
    app.project.items.addFolder("00_Render-Comps");
    app.project.items.addFolder("01_Pre-Comps");
    if (pal.grp.groupOne.resDrop.selection == 0 && this.parent.projName.text = "Project-Title" ) {
    alert("Please choose a Resolution");
    }else if (pal.grp.groupOne.resDrop.selection != 0){// ---- PROBLEM ----fix the "" marks on output
    app.project.items.addComp("'" this.parent.projName.text "'" "-Latin", width1, height1, 1, 10, 30);
    }
    app.project.items.addComp("text-style-full", width1, height1, 1, 10, 30);
    app.project.items.addComp("text-style-reduced", width1, height1, 1, 10, 30);
    //Resolution Variables
    var w;
    if (pal.grp.groupOne.resDrop.selection.index == 1){
    width1 = 1920;
    }else if (pal.grp.groupOne.resDrop.selection.index == 2){
    width1 = 3820;
    }else if (pal.grp.groupOne.resDrop.selection.index == 3){
    width1 = 2160;
    }else if (pal.grp.groupOne.resDrop.selection.index == 4){
    width1 = 6240;
    }
    var h;
    if (pal.grp.groupOne.resDrop.selection.index == 1){
    height1 = 1080;
    }else if (pal.grp.groupOne.resDrop.selection.index == 2){
    height1 = 2160;
    }else if (pal.grp.groupOne.resDrop.selection.index == 3){
    height1 = 2160;
    }else if (pal.grp.groupOne.resDrop.selection.index == 4){
    height1 = 2700;
    }
    }
    Ronan De lacy replied 5 years, 5 months ago 2 Members · 2 Replies
  • 2 Replies
  • Matt Volp

    November 19, 2020 at 11:45 am

    They are returning undefined because you haven’t defined them with

    var
  • Ronan De lacy

    November 19, 2020 at 2:16 pm

    Thanks Matt,

    The weird thing here is that the way I have it structured on the above post, it works sometimes and doesn’t others. I’m using Visual Studio Code and I’m a bit of a noob with it comes to ExtendScript. I cannot figure out what’s going on with it!

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