Creative Communities of the World Forums

The peer to peer support community for media production professionals.

  • Posted by Eric Sanderson on September 23, 2015 at 4:15 pm

    Ive been doing some extendScript training, and in an effort to better understand practical applications of a for loop in AE i rigged something very simple up to test, unfortunately with no result (no errors, but not the behavior I’m going for).

    i just have 10 or so layers lined up in a row on X. All with 50% opacity except for one randomly picked layer which is 100.

    Just trying to loop through to find the layer with 100% opacity, and move the expression’d layer to the same spot on X.

    if i change the “100” to “50”, the object will in fact jump to the last layer, that does happen to be at 50% opacity. But it just doesn’t seem to be finding the layer with 100% opacity, does nothing. Hope this is simple enough to make sense, or anyone has some better for exercises i could play with.

    Thanks

    for( i=1; i <= thisComp.numLayers; i++){

    curLayer = thisComp.layer(i);

    if(curLayer.transform.opacity == 100){
    curLayer.transform.xPosition
    }else{
    0
    }
    }

    Dan Ebberts
    replied 10 years, 7 months ago
    2 Members · 1 Reply
  • 1 Reply
  • Dan Ebberts

    September 23, 2015 at 8:46 pm

    More like this maybe:


    val = 0;
    for( i=1; i <= thisComp.numLayers; i++){
    if (i == index) continue; // skip myself
    curLayer = thisComp.layer(i);
    if(curLayer.transform.opacity == 100){
    val = curLayer.transform.xPosition;
    break;
    }
    }
    val

    Dan

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy