2 Replies Latest reply on May 7, 2016 6:33 PM by MATERHD

    Create an error, Script

    MATERHD

      Hey guys can help me check, how to properly use expressions to add, this is a very cool text using expressions, get a long period of not checking out the wrong language

       

       

      Code is as follows

      ------------------------------------------------------------------------------------

      var MyComp = app.project.activeItem;

      var na = MyComp.selectedLayers[0].selectedProperties[0].name;

      var swings = na + "Swings - IN";

      var timeOffset = na + "Offset - IN";

      zuo = "\"";

      var swings= "effect(" + zuo + swings + zuo + ")(Slider)";

      var timeOffset = "effect(" + zuo + timeOffset + zuo + ")(Slider)";

      var ft_Tb_Expression ="freq=" + freq + ";" + "amorti" + "=" + amorti + ";" + ";v=valueAtTime(time-timeOffset*textIndex/textTotal)[0];anim=2*Math.PI*v/100;amp=easeOut( v,0,100,100,0);Math.cos(anim*swings)*amp; v=valueAtTime(time-timeOffset*textIndex/textTotal[0];anim=2*Math.PI*v/100;amp=easeOut(v,0 ,100,100,0);Math.cos(anim*swings)*amp;";

      if (MyComp && MyComp.selectedLayers[0].selectedProperties[0]) {

      for (var i = 0;i < MyComp.selectedLayers.length; i += 1) {

      var currentLayer = MyComp.selectedLayers[i];

      var xpy = currentLayer.Effects.addProperty("ADBE Slider Control");

      xpy.name = na + "Swings - IN";

      var ypy = currentLayer.Effects.addProperty("ADBE Slider Control");

      ypy.name = na + "Offset - IN";

      currentLayer.effect(na + "Swings - IN")(1).setValue(3);

      currentLayer.effect(na + "Offset - IN")(1).setValue(6);

      for (var j = 0;j < currentLayer.selectedProperties.length; j += 1) {

      var currentProperty = currentLayer.selectedProperties[j];

      if (currentProperty.canSetExpression) {

      currentProperty.expression = ft_Tb_Expression;

      } else {

      alert("Select this property can not create expressions");

      }

      }

      }

      } else {

      alert("Please select a layer of a property");

      }

      ----------------------------------------------