Answers.Body: <p>Typo on line 2. It should be <code>thisComp.layer("DotMaster").index</code> not <code>-index</code>.</p>
  
  <p>Also, while it's valid, the first parameter to the <code>random</code> function on second last line <code>-randomTimeAmount</code> makes me nervous. I'd recommend changing it to <code>0-randomTimeAmount</code>. It's more explicit, and less prone to accidental typos.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-11-08T01:25:49.913Z
Answers.LastActivityDate: 2019-11-08T01:25:49.913Z
Answers.UserDisplayName: stib
Body: <p>I can't figure out why I'm getting the error... Any ideas?! I tried adding "var" at the beginning of the first line, but that didn't work. Not sure what to try now! Help anyone?</p>
  
  <p>Below is my code. The error reads: "object of type Layer found where a number, array or property is needed."</p>
  
  
  
  <pre><code>timeOffset=thisComp.layer("Mograph Control").effect("timeOffset(frames)")("Slider")/24;
  myIndex=thisComp.layer("DotMaster")-index;
  
  
  seedRandom=(index, timeless=false);
  randomTimeAmount=thisComp.layer("Mograph Control").effect("randomTime(frames)")("Slider")/24;
  randomActualAmount=random(-randomTimeAmount, randomTimeAmount);
  
  baseTime+(myIndex*timeOffset)+randomActualAmount;
  </code></pre>
  
  <p><a href="https://i.sstatic.net/KOF9j.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/KOF9j.png" alt="ae-error-img"></a></p>
  
Tags: <after-effects><animation><after-effects-expressions><motion-graphics>
Title: AE Expressions question - why isn't my code working?
UserDisplayName: Shir L
ThreadText: # AE Expressions question - why isn't my code working?
  
  (Asked by: username_0 on 2019-11-06)
  
  I can't figure out why I'm getting the error... Any ideas?! I tried adding "var" at the beginning of the first line, but that didn't work. Not sure what to try now! Help anyone?
  
  Below is my code. The error reads: "object of type Layer found where a number, array or property is needed."
  
  ```
  timeOffset=thisComp.layer("Mograph Control").effect("timeOffset(frames)")("Slider")/24;
  myIndex=thisComp.layer("DotMaster")-index;
  
  seedRandom=(index, timeless=false);
  randomTimeAmount=thisComp.layer("Mograph Control").effect("randomTime(frames)")("Slider")/24;
  randomActualAmount=random(-randomTimeAmount, randomTimeAmount);
  
  baseTime+(myIndex*timeOffset)+randomActualAmount;
  
  ```
  
  [![ae-error-img](https://i.sstatic.net/KOF9j.png)](https://i.sstatic.net/KOF9j.png)
  
  **Tags:** after-effects, animation, after-effects-expressions, motion-graphics
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2019-11-08. Score: 0
  
  Typo on line 2. It should be `thisComp.layer("DotMaster").index` not `-index`.
  
  Also, while it's valid, the first parameter to the `random` function on second last line `-randomTimeAmount` makes me nervous. I'd recommend changing it to `0-randomTimeAmount`. It's more explicit, and less prone to accidental typos.
  
  
  ---
  
  