Answers.Body: <p>This expression is <strong>not supported for Mask Path Property</strong>, because it's a <em>User Defined Property</em>, see the note of the error message. </p>
  
  <h3>Workaround</h3>
  
  <p><img src="https://i.sstatic.net/0byVw.jpg" alt="enter image description here"></p>
  
  <p><em>Mask Path animation once</em></p>
  
  <ol>
  <li><strong>Precompose your layer</strong> an with the animated mask (one time) by <em>Selecting the Layer > Right Click > Precompose</em> (and move all attributes in the new composition)</li>
  <li><strong>Enable Time Remapping</strong> on your new created composition <em>(Right Click on the composition > Time > Time Remapping)</em>, this extends the length of the layer to infinity</li>
  <li>Add <code>loopOut(type="cycle")</code> expression to the <strong>Time Remapping Property</strong> by holding <kbd>Alt</kbd> and clicking the stop watch left beside the properties name</li>
  </ol>
  
  <p><img src="https://i.sstatic.net/XDAG9.jpg" alt="enter image description here"></p>
  
  <p><em>Time Remapping enabled on the new composition and expresssion applied</em></p>
  
  <h3>Example</h3>
  
  <p><img src="https://i.sstatic.net/XGyhx.gif" alt="enter image description here"></p>
  
  <p><em>Example using 3 keyframes (third is same as first) and using <code>loopOut()</code> only</em></p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-05-04T19:21:41.233Z
Answers.LastActivityDate: 2015-05-04T20:17:33.223Z
Answers.LastEditDate: 2015-05-04T20:17:33.223Z
Answers.UserDisplayName: p2or
Answers.Body: <p>Another option if you don't want to create a pre-comp:</p>
  
  <p>Make your mask and set the keyframes and apply this expression to the mask path property:</p>
  
  <pre><code>valueAtTime(time % key(numKeys).time)
  </code></pre>
  
  <p>This is basically an implementation of the loopOut function, but it works for all properties, including custom ones like mask shapes.</p>
  
  <p><img src="https://i.sstatic.net/tarzg.png" alt="enter image description here"></p>
  
  <p><strong>How it works</strong>: <code>valueAtTime</code> returns the value of the property at a given time, so to loop the property we need a value that goes from 0 and rises until the playhead gets to the last keyframe and then the value loops back to 0. </p>
  
  <p>The expression <code>key(numKeys).time</code> returns the time of the last key (e.g. if there are 3 keys it will be <code>key(3).time</code>). The <code>%</code> operator is the modulus operator, which gives you the remainder when you divide the first term by the second. So if you find the remainder when dividing the current time (<code>time</code>) by the time of the last keyframe it will return a value that starts at 0 and rises in synch with <code>time</code> until the playhead reaches the last keyframe at which point the current time will divide exactly into the time of the last keyframe, so the remainder will go back to 0 then start rising in synch with the playhead, rinse, repeat. </p>
  
  <p>A useful feature of this expression is that you can speed it up and down by multiplying <code>time</code> by another factor, e.g. <code>time * 2 % key(numKeys).time</code> would play back the animation in double speed.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-05-06T03:36:19.160Z
Answers.LastActivityDate: 2015-11-01T13:02:44.260Z
Answers.LastEditDate: 2015-11-01T13:02:44.260Z
Answers.UserDisplayName: stib
Answers.Body: <pre><code>if (numKeys &gt;1 &amp;&amp; time &gt; key(numKeys).time){
    t1 = key(1).time;
    t2 = key(numKeys).time;
    span = t2 - t1;
    delta = time - t2;
    t = delta%span;
    valueAtTime(t1 + t)
  }else
    value
  </code></pre>
  
  <p>courtesy of the Master Expressionist Dan Ebberts in this thread:</p>
  
  <p><a href="https://forums.creativecow.net/thread/227/20661#22869" rel="nofollow noreferrer">https://forums.creativecow.net/thread/227/20661#22869</a></p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-01-17T22:32:48.460Z
Answers.LastActivityDate: 2017-01-17T22:32:48.460Z
Answers.UserDisplayName: Roei Tzoref
Body: <p>I'm trying to make a <strong>loop from an animated mask</strong>, but each time I introduce my loop expression: <code>loopOut (type="cycle", numKeyframes = 0)</code>, After Effects is telling me that:</p>
  
  <blockquote>
    <p>"Expression is deactivated, because of line 1 and that the layer doesn't allow loop"</p>
  </blockquote>
  
  <p>I have tried to use the <strong>pre-expressions</strong> from the application, but it still doesn't work:</p>
  
  <p><img src="https://i.sstatic.net/mo9XA.png" alt="enter image description here"></p>
  
  <p>What I'm doing wrong or what else can I do to loop the mask?</p>
  
Tags: <after-effects><after-effects-expressions>
Title: How to loop an animated mask?
UserDisplayName: Patricia Atxurra
ThreadText: # How to loop an animated mask?
  
  (Asked by: username_0 on 2015-05-03)
  
  I'm trying to make a **loop from an animated mask**, but each time I introduce my loop expression: `loopOut (type="cycle", numKeyframes = 0)`, After Effects is telling me that:
  
  > "Expression is deactivated, because of line 1 and that the layer doesn't allow loop"
  
  I have tried to use the **pre-expressions** from the application, but it still doesn't work:
  
  ![enter image description here](https://i.sstatic.net/mo9XA.png)
  
  What I'm doing wrong or what else can I do to loop the mask?
  
  **Tags:** after-effects, after-effects-expressions
  
  
  ---
  
  ## 3 answers
  
  ### Answer by username_1 on 2015-05-04. Score: 5
  
  This expression is **not supported for Mask Path Property**, because it's a *User Defined Property*, see the note of the error message.
  
  ### Workaround
  
  ![enter image description here](https://i.sstatic.net/0byVw.jpg)
  
  *Mask Path animation once*
  
  1. **Precompose your layer** an with the animated mask (one time) by *Selecting the Layer > Right Click > Precompose* (and move all attributes in the new composition)
  2. **Enable Time Remapping** on your new created composition *(Right Click on the composition > Time > Time Remapping)*, this extends the length of the layer to infinity
  3. Add `loopOut(type="cycle")` expression to the **Time Remapping Property** by holding `Alt` and clicking the stop watch left beside the properties name
  
  ![enter image description here](https://i.sstatic.net/XDAG9.jpg)
  
  *Time Remapping enabled on the new composition and expresssion applied*
  
  ### Example
  
  ![enter image description here](https://i.sstatic.net/XGyhx.gif)
  
  *Example using 3 keyframes (third is same as first) and using `loopOut()` only*
  
  
  ---
  
  ### Answer by username_2 on 2015-05-06. Score: 4
  
  Another option if you don't want to create a pre-comp:
  
  Make your mask and set the keyframes and apply this expression to the mask path property:
  
  ```
  valueAtTime(time % key(numKeys).time)
  
  ```
  
  This is basically an implementation of the loopOut function, but it works for all properties, including custom ones like mask shapes.
  
  ![enter image description here](https://i.sstatic.net/tarzg.png)
  
  **How it works**: `valueAtTime` returns the value of the property at a given time, so to loop the property we need a value that goes from 0 and rises until the playhead gets to the last keyframe and then the value loops back to 0.
  
  The expression `key(numKeys).time` returns the time of the last key (e.g. if there are 3 keys it will be `key(3).time`). The `%` operator is the modulus operator, which gives you the remainder when you divide the first term by the second. So if you find the remainder when dividing the current time (`time`) by the time of the last keyframe it will return a value that starts at 0 and rises in synch with `time` until the playhead reaches the last keyframe at which point the current time will divide exactly into the time of the last keyframe, so the remainder will go back to 0 then start rising in synch with the playhead, rinse, repeat.
  
  A useful feature of this expression is that you can speed it up and down by multiplying `time` by another factor, e.g. `time * 2 % key(numKeys).time` would play back the animation in double speed.
  
  
  ---
  
  ### Answer by username_3 on 2017-01-17. Score: 1
  
  ```
  if (numKeys >1 && time > key(numKeys).time){
    t1 = key(1).time;
    t2 = key(numKeys).time;
    span = t2 - t1;
    delta = time - t2;
    t = delta%span;
    valueAtTime(t1 + t)
  }else
    value
  
  ```
  
  courtesy of the Master Expressionist Dan Ebberts in this thread:
  
  <https://forums.creativecow.net/thread/227/20661#22869>
  
  
  ---
  
  