Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions For Loop Statement combined with Hover-Over Effect

  • For Loop Statement combined with Hover-Over Effect

    Posted by Mateo Baldasare on April 21, 2023 at 1:40 pm

    Hi there!

    I’m trying to make a hover-over effect activated by different shape layers. So each time one of the moving circles gets closer to the static circle layer, its size changes.

    I managed to change the size but it only works with one shape layer, then the rest are ignored. I’ve attached a video for reference.

    This is the expression that I used:

    l = 0;

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

    curLayer = thisComp.layer(i);

    if(curLayer.name.slice(0, 3) == “C_M” && curLayer.effect(“Circle Moving”)(“Fill Color”) == 1) {

    pointA = curLayer.toComp(position)[1];

    pointB = thisLayer.toComp(position)[1];

    l = length(pointA, pointB);

    s = ease(l,0,200,53,33);

    }

    }

    [s,s]

    What am I missing? Or is there a better way to achieve the same result?
    Thanks!

    Mateo

     

    Brie Clayton replied 5 months ago 3 Members · 3 Replies
  • 3 Replies
  • Dan Ebberts

    April 21, 2023 at 3:46 pm

    I haven’t tested this, but I think, as you loop through the layers, you need to save off the shortest distance, and use that at the end, like this:

    l = 0;
    lMin = 999999;
    for( i=1; i <= thisComp.numLayers; i++){
    curLayer = thisComp.layer(i);
    if(curLayer.name.slice(0, 3) == "C_M" && curLayer.effect("Circle Moving")("Fill Color") == 1) {
    pointA = curLayer.toComp(position)[1];
    pointB = thisLayer.toComp(position)[1];
    l = length(pointA, pointB);
    lMin = Math.min(l,lMin);
    }
    }
    s = ease(lMin,0,200,53,33);
    [s,s]
  • Mateo Baldasare

    April 25, 2023 at 4:32 am

    Thanks so much for this, Dan! it works great 😃

  • Brie Clayton

    April 25, 2023 at 3:06 pm

    Thank you again, Dan!

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