Answers.Body: <p>Totally possible, but there are some problems with your expression.</p>
  
  <pre><code>n = comp("myparentComp").layer("myLayer").marker.key(time); 
  </code></pre>
  
  <p>In this line <code>n</code> is going to return a marker key object. However the last part of the line uses the current time in the method <code>marker.key(time)</code>. This won't work. The <code>marker.key()</code> function expects an int referring to the number of the marker (1-indexed, so the first marker is <code>marker.key(1)</code>, because WTF adobe). A marker key has a <code>time</code> property, which is probably where you're getting confused. Also then you're treating <code>n</code> as if it's an integer, and you use a variable <code>marker</code> without declaring it or giving it a value.</p>
  
  <p>If you want the animation to trigger on the first marker, it should look like this:</p>
  
  <pre class="lang-js prettyprint-override"><code>var marker1time = comp("myparentComp").layer("myLayer").marker.key(1).time;
  if(time &lt; marker1time){ 
    t = 0; //hold the animation until the first marker
  } else {
      t=time-marker1time; //will start at 0 at the point where time == marker1time
  }
  thisProperty.valueAtTime(t);
  </code></pre>
  
  <p>Some basic JS tutorials would probably help. I recommend the <a href="https://www.w3schools.com/js/default.asp" rel="nofollow noreferrer">w3Schools</a> ones, they're web-design focused, but almost all JS tutes are.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-01-29T10:16:04.253Z
Answers.Text: Nice thanks, it worked. I got another question, would that be possible to have this expression for the animation to react to every markers of `comp("myparentComp").layer("myLayer")` ? 
  
  This one works for the markers on the layer but I can't make it work with the one you wrote. 
  
  `n = marker.nearestKey(time).index; 
  if(time < marker.key(n).time){ n=n-1;
  }
  if(n==0){ n=1
  }
  t=time-marker.key(n).time;
  thisProperty.valueAtTime(t)`
Answers.UserDisplayName: Nicolas Nydegger
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-01-29T11:45:03.670Z
Answers.Text: I don't quite understand what you're trying to do. What do you mean "have the animation react"?
Answers.UserDisplayName: stib
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-01-29T01:54:18.600Z
Answers.LastActivityDate: 2019-01-29T01:54:18.600Z
Answers.UserDisplayName: stib
Body: <p>Is it possible to trigger animation from parent comp layer? I have been trying this expression with my basic coding skills but couldn't make it work. </p>
  
  <pre><code>n = comp("myparentComp").layer("myLayer").marker.key(time); 
  if(time &lt; marker.key(n).time){ n=n-1;
  }
  if(n==0){ n=1
  }
  t=time-marker.key(n).time;
  thisProperty.valueAtTime(t)
  </code></pre>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-01-28T23:38:23.407Z
Comments.Text: Sounds definitely doable but I need some more data. What are you trying to "trigger"?
Comments.UserDisplayName: Spencer
Tags: <video><after-effects><after-effects-expressions>
Title: Marker animation trigger from parent composition
UserDisplayName: Nicolas Nydegger
ThreadText: # Marker animation trigger from parent composition
  
  (Asked by: username_0 on 2019-01-28)
  
  Is it possible to trigger animation from parent comp layer? I have been trying this expression with my basic coding skills but couldn't make it work.
  
  ```
  n = comp("myparentComp").layer("myLayer").marker.key(time); 
  if(time < marker.key(n).time){ n=n-1;
  }
  if(n==0){ n=1
  }
  t=time-marker.key(n).time;
  thisProperty.valueAtTime(t)
  
  ```
  
  **Tags:** video, after-effects, after-effects-expressions
  
  > **Comments:**
  > **username_1**: Sounds definitely doable but I need some more data. What are you trying to "trigger"?  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2019-01-29. Score: 0 | Accepted answer
  
  Totally possible, but there are some problems with your expression.
  
  ```
  n = comp("myparentComp").layer("myLayer").marker.key(time); 
  
  ```
  
  In this line `n` is going to return a marker key object. However the last part of the line uses the current time in the method `marker.key(time)`. This won't work. The `marker.key()` function expects an int referring to the number of the marker (1-indexed, so the first marker is `marker.key(1)`, because WTF adobe). A marker key has a `time` property, which is probably where you're getting confused. Also then you're treating `n` as if it's an integer, and you use a variable `marker` without declaring it or giving it a value.
  
  If you want the animation to trigger on the first marker, it should look like this:
  
  ```js
  var marker1time = comp("myparentComp").layer("myLayer").marker.key(1).time;
  if(time < marker1time){ 
    t = 0; //hold the animation until the first marker
  } else {
      t=time-marker1time; //will start at 0 at the point where time == marker1time
  }
  thisProperty.valueAtTime(t);
  
  ```
  
  Some basic JS tutorials would probably help. I recommend the [w3Schools](https://www.w3schools.com/js/default.asp) ones, they're web-design focused, but almost all JS tutes are.
  
  > **Comments:**
  > **username_0**: Nice thanks, it worked. I got another question, would that be possible to have this expression for the animation to react to every markers of `comp("myparentComp").layer("myLayer")` ?   This one works for the markers on the layer but I can't make it work with the one you wrote.   `n = marker.nearestKey(time).index;  if(time < marker.key(n).time){ n=n-1; } if(n==0){ n=1 } t=time-marker.key(n).time; thisProperty.valueAtTime(t)`  
  > **username_2**: I don't quite understand what you're trying to do. What do you mean "have the animation react"?  
  
  ---
  
  