Answers.Body: <p>Well, I found my own answer. I just needed to access the source property.</p>
  <pre><code>var comp = app.project.activeItem.selectedLayers[0].source;
  alert(comp);
  </code></pre>
  <p><a href="https://i.sstatic.net/bA3Yb.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/bA3Yb.png" alt="enter image description here" /></a></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-08-20T18:39:00.283Z
Answers.LastActivityDate: 2020-08-20T18:39:00.283Z
Answers.UserDisplayName: LetTheWritersWrite
Body: <p>In this case, I am selecting a precomp in the timeline but the problem is that this code below returns the AVLayer object instead of a CompItem object. How can I select the layer but get it as aCompItem. I need to do this because I want to then access the layers inside the precomp.</p>
  <pre><code>var comp = app.project.activeItem.selectedLayers[0];
  alert(comp);
  </code></pre>
  <p><a href="https://i.sstatic.net/P9DRk.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/P9DRk.png" alt="enter image description here" /></a></p>
  
Tags: <after-effects><after-effects-scripting>
Title: Access a precomp as a CompItem not as an AV Layer
UserDisplayName: LetTheWritersWrite
ThreadText: # Access a precomp as a CompItem not as an AV Layer
  
  (Asked by: username_0 on 2020-08-20)
  
  In this case, I am selecting a precomp in the timeline but the problem is that this code below returns the AVLayer object instead of a CompItem object. How can I select the layer but get it as aCompItem. I need to do this because I want to then access the layers inside the precomp.
  
  ```
  var comp = app.project.activeItem.selectedLayers[0];
  alert(comp);
  
  ```
  
  [![enter image description here](https://i.sstatic.net/P9DRk.png)](https://i.sstatic.net/P9DRk.png)
  
  **Tags:** after-effects, after-effects-scripting
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2020-08-20. Score: 1
  
  Well, I found my own answer. I just needed to access the source property.
  
  ```
  var comp = app.project.activeItem.selectedLayers[0].source;
  alert(comp);
  
  ```
  
  [![enter image description here](https://i.sstatic.net/bA3Yb.png)](https://i.sstatic.net/bA3Yb.png)
  
  
  ---
  
  