Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Simulating web cursor (arrow/hand) rollover

  • Simulating web cursor (arrow/hand) rollover

    Posted by Tim Drage on October 8, 2010 at 1:02 pm

    Hi,

    I am working on an animation of a website, simulating the cursor, rollovers etc all in AE. I have button rollovers working OK (based this script – https://forums.creativecow.net/archivepost/2/405515) but I would also like the cursor graphic to switch from arrow to hand pointer when it rolls over any of the multiple buttons in the comp.

    The bit I can’t figure out how to do is how I’d expand the script to detect whether it’s over any one of several layers?

    Any ideas would be greatly appreciated, thanks!
    Tim

    Tim Drage replied 15 years, 7 months ago 2 Members · 2 Replies
  • 2 Replies
  • Dan Ebberts

    October 8, 2010 at 7:21 pm

    Here’s one that checks to see if the upper left corner of the layer with the expression is over any of the layers in the array “layerNames”. If it is, it gives the index of that layer. If not, the result it zero. Might get you headed in the right direction.

    layerNames = ["Layer 1","Layer 2","Layer 3"]

    pointer = [0,0]; // upper left corner

    target = null;
    for (i = 0; i < layerNames.length; i++){
    L = thisComp.layer(layerNames[i]);
    p = L.fromWorld(toWorld(pointer));
    if (p[0] >= 0 && p[0] <= L.width && p[1] >= 0 && p[1] <= L.height){
    target = L;
    break;
    }
    }

    if (target == null) 0 else L.index

    Dan

  • Tim Drage

    October 12, 2010 at 2:37 pm

    Thanks very much for the quick reply, just had the chance to give it a test and it’s going to work a treat I think. 🙂

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