Forum Replies Created

Page 9 of 32
  • The last line modifies the original string using a regular expression.

    Regular expressions can be from very simple to fairly complicated, and not worth the effort to learn if you plan to use very occasionnaly. Most of the time you’ll find the regular expression suited to your needs with a quick search at https://stackoverflow.com/ (in the search, specify RegExp + javascript + what you want).

    It’s actually possible to do what you wanted without a RegExp, the code is just longer but in the end the result is the same. See for instance this thread: https://forums.creativecow.net/thread/227/21144#21144 (the part that modifies the thousands is under if (commas){…}).

    Xavier

  • The last line modifies the original string using a regular expression.

    Regular expressions can be from very simple to fairly complicated, and not worth the effort to learn if you plan to use very occasionnaly. Most of the time you’ll find the regular expression suited to your needs with a quick search at https://stackoverflow.com/ (in the serach, specify RegExp + javascript + what you want).

    It’s actually possible to do what you wanted without a RegExp, the code is just longer but in the end it’s the same. See for instance this thread: https://forums.creativecow.net/thread/227/21144#21144 (the part that modifies the thousands is under if (commas){…}).

    Xavier

  • There are many many threads on counters on this forum, so many that it’s hard to find the right one…

    The following should work:

    // provide number to format. For instance:
    tStart = inPoint;
    tEnd = inPoint + 5;
    vStart = 0;
    vEnd = 13800;
    x = linear(time, tStart, tEnd, vStart, vEnd);

    // transform number to a string with 0 decimals
    x = x.toFixed(0);

    // provide separator
    separator = ",";

    // final result:
    x.replace(/(\d)(?=(\d{3})+(?!\d))/g, "$1"+separator);

    Xavier

  • Xavier Gomez

    May 17, 2016 at 8:43 pm in reply to: File Import question

    My mistake !
    i messed up, it was as you said: file.parent, not file.parentFolder

    The path of a file/folder is the portion of the absoluteURI without the file name, so it’s same as the absoluteURI of the parent folder.

    In the end, does it work ?

  • Xavier Gomez

    May 17, 2016 at 7:15 pm in reply to: File Import question

    To check that the project file and the folder containing the imported file are both in the same folder, you can compare folder objects like this:

    if (app.project.file.parentFolder == file.parentFolder.parentFolder){
    // do stuff
    }
    else{
    alert(“!”);
    };

    Or you can compare paths (strings):

    if (app.project.file.path === file.parentFolder.path){
    // do stuff
    };

    Xavier

  • Xavier Gomez

    May 17, 2016 at 6:46 pm in reply to: Text Counter Connected to Layers Z-Rotation

    ***If you want exactly 2 decimals, you can use:

    … // same beginning
    x = linear(rot, minRot, maxRot, minValue, maxValue);
    x.toFixed(2);

    ***And if you want at most 2 decimals:


    x = linear(rot, minRot, maxRot, minValue, maxValue);
    Math.floor(x*100)/100;

    Xavier

  • Xavier Gomez

    May 17, 2016 at 5:41 pm in reply to: Text Counter Connected to Layers Z-Rotation

    This might work:

    minRot = -75;
    maxRot = 75;
    minValue = 0;
    maxValue = 6;
    rot = thisComp.layer("Shape Layer 3").transform.zRotation;
    linear(rot, minRot, maxRot, minValue, maxValue);

    Xavier

  • Xavier Gomez

    May 17, 2016 at 4:27 pm in reply to: Countdown clock – but keep spacing for 1

    There is no picture attached to your post.
    Could it be that you are not using a monospaced font ?

    Xavier

  • Xavier Gomez

    May 16, 2016 at 4:00 pm in reply to: dropdown interaction issue…

    onDDchange is the function itself, while onDDchange() is its result (which is undefined since the function returns nothing).
    You want to assign the function, not its result.

    After i answered you i came across this article:
    https://www.davidebarranca.com/2013/09/scriptui-tip-decoupling-components-event-handling/.
    It might interest you. As far as i’m concerned, bubbling or no bubbling gives me headaches, i actually use code similar to the one in my answer and i’m fine with it.

    Xavier

  • Xavier Gomez

    May 15, 2016 at 7:13 pm in reply to: How to get AV Layer’s duration using script?

    Layers don’t have a duration attribute. Only AVItems do (things in the project panel).
    You can get the duration of the layer itself from its inPoint and outPoint, or the duration of its source by: layer.source.duration (not all layers have a source though).

    Xavier

Page 9 of 32

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