Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Multiple keyframe values in an alert

  • Multiple keyframe values in an alert

    Posted by Ben Christie on December 9, 2015 at 6:48 pm

    Below is snippet of code that works really well in my function for pulling out the individual curves between keyframes.

    I currently am writing the result I get back to an alert.

    Basically the code below is written in a “loop” so if you are trying to get the curve between two keyframes it works really well but if you have 10 keyframes you get an alert for each set of keyframes.

    Does anyone have any suggestions on how I can compile all of the keyframe values into one alert?

    I’m really struggling with this.

    Thanks!

    function writeCubicBeziers(){
    var curItem = app.project.activeItem;
    var selectedLayers = curItem.selectedLayers;
    var selectedProperties = app.project.activeItem.selectedProperties;
    if (selectedLayers == 0){
    alert("Please Select at least one Layer");
    }
    else if(selectedLayers !=0){
    for (var i = 0; i < selectedLayers.length; i++){
    for (var f in selectedProperties){
    var currentProperty = selectedProperties[f];
    if (currentProperty.numKeys > 1){
    for(var i = 1; i < currentProperty.numKeys; i++){
    var t1 = currentProperty.keyTime(i);
    var t2 = currentProperty.keyTime(i+1);
    var val1 = currentProperty.keyValue(i);
    var val2 = currentProperty.keyValue(i+1);
    var delta_t = t2-t1;
    var delta = val2-val1;

    Ben Christie replied 10 years, 2 months ago 2 Members · 7 Replies
  • 7 Replies
  • Dan Ebberts

    December 9, 2015 at 7:48 pm

    I’d just add them all to one string variable, and then alert that after the loop.

    var myAlert = “”;

    (each time you have a new message to add:)

    myAlert += newMessage + “\r”;

    (then, finally:)

    alert(myAlert);

    Dan

  • Ben Christie

    December 10, 2015 at 12:01 am

    Ah that idea makes sense, but aren’t you just alerting the “myAlert” right away so it’s still not able to get repeated alerts?

    It seems like when I tried this that what was happening or nothing happens.

  • Ben Christie

    December 16, 2015 at 11:54 pm

    Any more explanation on this? I’m still having a hard time figuring it out.

    myAlert + = newMessage + “\r”; isn’t working well for some reason. It always comes back with “line whatever has no value.”

    Help would be great.

    Thanks!

  • Dan Ebberts

    December 17, 2015 at 12:08 am

    Try += instead of + =

    Dan

  • Ben Christie

    March 8, 2016 at 6:51 pm

    Hey Dan,

    I got this to work but the problem now is every time the button is clicked all of the keyframes are added to the alert. They are never cleared, just constantly added. So if I end up clicking the button 12 times I’ll have 12 dupes of each keyframe variant until I close AE.

    Any thoughts?


    myAlert = "keyframe: " + i +" Cubic-bezier["+x1r+", "+y1r +", "+x2r+", "+y2r +"]";

    newMessage += myAlert + "\r";

    alert(newMessage)

  • Dan Ebberts

    March 8, 2016 at 8:16 pm

    Try adding this after the alert:

    newMessage = “”;

    (or even better, somewhere at the top of the button handling function).

    Dan

  • Ben Christie

    March 10, 2016 at 10:24 pm

    Perfect! I got the whole thing to work!

    Thanks for your continued help.

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