Activity › Forums › Adobe After Effects Expressions › Opacity Rollover Expression Based on Null Proximity
-
Opacity Rollover Expression Based on Null Proximity
Posted by Dan Fassnacht on February 10, 2017 at 6:55 pmHey All,
Basically I’m trying to have a mouse rollover an icon and have it trigger the opacity of a highlight, similar to a rollover on a website. The opacity doesn’t need to ease up or anything, just on and off. I’m just trying to find a better way to do this than manually.
Thanks any info!
Dan
Mariusz Ślemp replied 6 years, 8 months ago 3 Members · 9 Replies -
9 Replies
-
Dan Ebberts
February 10, 2017 at 7:42 pmIn its simplest form, probably something like this:
dTrigger = 100; // trigger within 100 px
d = length(thisComp.layer(“mouse”).position,position);
d < dTrigger ? 100 : 0Dan
-
Dan Fassnacht
February 10, 2017 at 8:58 pmThanks Dan, that’s perfect.
Is there any version of this that would move the position of a layer if it’s rolled over. So lets say I roll over an image with the mouse and it pushes the image down etc.
Thanks!
Dan
-
Dan Ebberts
February 10, 2017 at 9:12 pmYou could add a Transform effect to your layer and add something like this to the effect’s Position property:
dTrigger = 100; // trigger within 100 px
d = length(thisComp.layer(“mouse”).position,position);
y = d < dTrigger ? 100 : 0;
value + [0,y]Dan
-
Dan Fassnacht
February 10, 2017 at 10:34 pmGreat thanks Dan.
I had one more question, is there any way to Ease the movement/opacity so it’s not on/off.
Thanks again, this is going to save me alot of time.
-
Dan Ebberts
February 10, 2017 at 10:48 pmLike this maybe:
// Opacity
dMax = 100;
dMin = 0;
d = length(thisComp.layer(“mouse”).position,position);
ease(d,dMin,dMax,100,0)// Transform effect/Position
dMax = 100;
dMin = 0;
yOffset = 100;
d = length(thisComp.layer(“mouse”).position,position);
y = ease(d,dMin,dMax,yOffset,0);
value + [0,y]Dan
-
Dan Fassnacht
February 10, 2017 at 11:04 pmGreat! Thanks for taking the time Dan, much appreciated.
Best,
Dan
-
Dan Fassnacht
February 18, 2017 at 9:13 pmHi Dan,
I had one more question on this.
Is there anyway to have the trigger expression, trigger something that isn’t necessarily square?
So basically I’m rolling over images that are rectangular that have different pixel proximities depending if I come from the side or top of the rectangle with the mouse cursor.
Thanks for any info!
– Dan
-
Dan Ebberts
February 18, 2017 at 9:23 pmI think that’s a much more complex expression. The target layer expression would have to calculate its own bounding box in the comp, figure out which edge the cursor is closest to, and calculate the distance based on that. Do-able but challenging. If I wasn’t right in the middle of a project, I’d take a crack at it. Maybe somebody else will jump in.
Dan
-
Mariusz Ślemp
September 6, 2019 at 10:46 amHi Dan,
It is a very useful technique, thanks for this.
It’s possible to do the same with the scale of the object?Thanks for any info!
Mariusz
Reply to this Discussion! Login or Sign Up