Accessing AVLayers
Posted: August 28th, 2009, 4:49 am
Hi !
I need to access AV Layers in a comp. I use the following code to create a parent composition with a child comp inside it.
That works fine. I´ve looked in the afx scripting guide and found this:
That seems to be the way to acces the layer in a comp. But I don´t get it to work.
to get the layer index and item index I tried:
( I got an error when trying to get the .index property of "myMainComp )
I´m really new to scripting for afx so I would appreciate all the coments and tips I could get !
Thanks alot,
- J
I need to access AV Layers in a comp. I use the following code to create a parent composition with a child comp inside it.
Code: Select all
{
var myProject = app.project; // declare the project name
var myComp = myProject.activeItem; // declare the comp name
var myParentComp;
var myParentCompName = "parentComp";
var myParentCompWidth= 960;
var myParentCompHeight = 360;
var myParentCompPixelAspect = 1;
var myParentCompDuration = 5;
var myParentCompFramerate = 25;
createParentComp(); // create the main comp
createChildComp(); // create sub comp;
function createParentComp()
{
myParentComp = app.project.items.addComp(myParentCompName,myParentCompWidth,myParentCompHeight,myParentCompPixelAspect,myParentCompDuration,myParentCompFramerate);
}
function createChildComp()
{
var myChildCompName = "childComp";
var myChildCompWidth= myParentComp.width*.5;
var myChildCompHeight = myParentComp.height*.5;
// create child comp
var newComp = app.project.items.addComp(myChildCompName,myChildCompWidth,myChildCompHeight,myParentCompPixelAspect,myParentCompDuration,myParentCompFramerate);
// add child to mainComp
var myLayer = myParentComp.layers.add(newComp);
}
}
Code: Select all
app.project.item(index).layer(index);
to get the layer index and item index I tried:
( I got an error when trying to get the .index property of "myMainComp )
Code: Select all
var myLayerIndex = myLayer.index;
var myMainId = myMainComp.id;
Thanks alot,
- J