Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects CTI moving in time weirdly

  • CTI moving in time weirdly

    Posted by Sebastian Moreno on October 24, 2017 at 11:42 am

    Hi all
    I am doing a quick script to move the current time indicator to a new time given by a edittext field.
    so far works to go backwards but behaves differently when I try to go forward in time:

    btn01.onClick = function () {

    var textInput = Input.text;
    var active = app.project.activeItem;

    active.time -= textInput; //works fine

    }

    btn02.onClick = function () {

    var textInput = Input.text;
    var active = app.project.activeItem;

    active.time += textInput;

    // works in a digit + digit way
    // so if I entered 1 and the current time is 1 it would be: 1+1=11

    }

    any ideas how this can be solved?

    Thanks in advance

    Walter Soyka replied 8 years, 6 months ago 2 Members · 1 Reply
  • 1 Reply
  • Walter Soyka

    October 24, 2017 at 1:34 pm

    activeTime is being recast as a string because textInput is a string. Therefore, the number 1 is being recast as a string ‘1’ and then concatenated with another string ‘1’, yielding ’11’. You want to make sure that your textInput is understood explicitly as a number.

    Try:

    activeTime += parseFloat(textInput);

    Walter Soyka
    Designer & Mad Scientist at Keen Live [link]
    Motion Graphics, Widescreen Events, Presentation Design, and Consulting
    @keenlive   |   RenderBreak [blog]   |   Profile [LinkedIn]

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