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

switch case: Must use string value?

$
0
0

in the example below I have two items in a switch case. The first one works and the second doesn't. In the second one I tried using a variable to concatinate the string for the case. For some reason as soon as I do this it doesn't locate the second case. It seems like it should work...

 

 

for (c = 1; c<= numItems; c++) {

    var comp = app.project.items[c];

    var scale = 100;

 

 

    if (comp instanceof CompItem) {                                  

 

 

        for (i = 1; i <= comp.numLayers; i++) {                       

           

            switch(comp.layer(i).name) {

                                            

               case "textLines_NFLAM":  //This one works

                    targetWidth = 1400;

                    comp.layer(i).scale.setValue ([scale, scale]);

                    setTextLayer_caseSensitive(comp.layer(i), lineValue);

 

 

                    if(scaleTextLayer(comp.layer(i), comp.layer(i).sourceRectAtTime(1, true).width, targetWidth)){

                        modifiedLayers.push(comp.layer(i));

                    }                          

                break;

               

               

               var showName = "TA";

               

                case "textLines_" + showName:     //This one doesn't work unless I change it to:  case "textLines_TA":

                    targetWidth = 1430;

                    comp.layer(i).scale.setValue ([scale, scale]);

                    setTextLayer_caseSensitive(comp.layer(i), lineValue);

 

 

                    if(scaleTextLayer(comp.layer(i), comp.layer(i).sourceRectAtTime(1, true).width, targetWidth)){

                        modifiedLayers.push(comp.layer(i));

                    }                           

                break;

            }

        }

    }

}


Viewing all articles
Browse latest Browse all 2143

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>