Quantcast
Channel: Adobe Community : Discussion List - After Effects Scripting
Viewing all articles
Browse latest Browse all 2143

Drop Down List index - my script does not recognize the index line in my function

$
0
0

AE script Community-

 

I am a designer not a programmer so bare with me.  I'm just trying something simple, baby steps and I can't for the life of me to get this simple script to work.

 

I saw the script QUICK ADD and thought I would try to mimic this script for myself as a challenge.  I have watched David Torno's videos on Pro Video Coalition and made a simple Script UI from his example.  I searched for my answer on these forums here and tried to cobble together a simple script from the examples within these forums and can not get it to recognize the indices for my DROP DOWN LIST.  Here is my simple script:

 

{

function myScript(thisObj){

    function myScript_buildUI(thisObj){

        var myPanel = (thisObj instanceof Panel) ? thisObj : new Window("palette", "Add This", undefined, {resizeable:true});

       

        res = "group{orientation:'row', alignment:['fill', 'fill'], alignChildren:['fill', 'fill'],\

                    groupOne: Group{orientation:'row', alignment:['fill', 'fill'], alignChildren:['fill', 'top'],\

                        myStaticText: StaticText{text:'New:'},\

                        myDropDownList: DropDownList{properties:{items:['Solid', 'Light']}},\

                },\

                    groupTwo: Group{orientation:'row', alignment:['fill', 'fill'], alignChildren:['fill', 'top'],\

                        myButton: Button{text:'Add'},\

                },\

                }";

       

        myPanel.grp = myPanel.add(res);

 

 

        //Defaults

        myPanel.grp.groupOne.myDropDownList.selection = 0;

              myPanel.grp.groupTwo.myButton.onClick = myButtonClick;

 

 

        //Setup panel sizing

        myPanel.layout.layout(true);

        myPanel.grp.minimumSize = myPanel.grp.size;

       

        //Make the panel resizeable

        myPanel.layout.resize();

        myPanel.onResizing = myPanel.onResize = function(){this.layout.resize()};

                    

        return myPanel;

    }      

 

 

function myButtonClick() {

    var myComp = app.project.activeItem;

   

    if (myComp != null && myComp instanceof CompItem) {

 

 

        if (myPanel.grp.groupOne.myDropDownList.selection.index == 0){

               myComp.layers.addSolid([0,0,0],"MySolid", myComp.width, myComp.height, 1)

 

 

      } else if (myPanel.grp.groupOne.myDropDownList.selection.index == 2){

               myComp.layers.addLight("Light", [myComp.width/2, myComp.height/2]);

 

 

        }

    }

}

 

 

// Make floating window

    var myScriptPal = myScript_buildUI(thisObj);

   

    if((myScriptPal != null) && (myScriptPal instanceof Window)){

        myScriptPal.center();

        myScriptPal.show();

    }

 

 

}

 

 

myScript (this);

}

 

 

If I comment out the lines

 

if (myPanel.grp.groupOne.myDropDownList.selection.index == 0){ and if (myPanel.grp.groupOne.myDropDownList.selection.index == 1){

 

the script will add the SOLID and the LIGHT.  But it will never work with these lines active - The ADD button does nothing.

 

I could just make use of the onChange with the drop down list, but I want to figure out how to connect onClick actions to the drop down list.

 

I copied this script piece from the forum and changed it to work with my script, but nothing seems to work:

 

buttonOne.onClick = onButtonOneClick;

function onButtonOneClick() {

     if (myPalette.dropdownlistOne.selection.index == 0) {

          // do this

     } else {

          // do this instead

     }

}

Can someone take a quick look at my top script and tell me why it will not work?  I've pretty much pulled out the last bit of hair I have over this - simple problem????

 

Thank you in advance.


Viewing all articles
Browse latest Browse all 2143