Skip to main content
Inspiring
April 2, 2021
Answered

Move one layer index to a new specified index

  • April 2, 2021
  • 2 replies
  • 411 views

I have a composition. 
I have 300+ layers. I want to take one layer and move it to a different layer index. Seems simple. I tried moveBefore and moveAfter but its not working right.

I call the comp in question and store it as a variable.

Then i call a particular layers index, and then i want to shuffle it to above another layer in the same comp.

    getAComp(compSearchingFor); //this returns mNewComp
    if (typeSelect.selection == 2){ // this is a dropdown that is specified
        myLayer = mNewComp.layer(62); //establish the layer i want to move
        alert(myLayer.name);//alert me just to show this works
        mLayer.moveBefore("Layer name");// i tried this with index too, no luck. the error says mLayer is undefined.
    }

 

This topic has been closed for replies.
Correct answer Cefalopodo

First of all:  never hardcode a layer index. If you need to look for a specific control layer, do it by name. 

Second: Have you tryed to hardcode mNewComp.layer(1)?

 

2 replies

Cefalopodo
CefalopodoCorrect answer
Inspiring
April 2, 2021

First of all:  never hardcode a layer index. If you need to look for a specific control layer, do it by name. 

Second: Have you tryed to hardcode mNewComp.layer(1)?

 

Inspiring
April 2, 2021

solved. I had some bad naming. all good.