<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>

CC BY-SA 4.0
2020-08-20T18:39:00.283Z
2020-08-20T18:39:00.283Z
LetTheWritersWrite
<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>

<after-effects><after-effects-scripting>
Access a precomp as a CompItem not as an AV Layer
LetTheWritersWrite
# 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);

**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);


---

