Interactive Click

Moderators: Disciple, zlovatt

Post Reply
charliebrown
Posts: 8
Joined: June 10th, 2008, 9:16 am

Hi, :)

I am setting up a GUI interface project that mimics FLASH interaction/ MAC OSX pop scale effect.

Original credit to http://jjgifford.com/expressions/geometry/length.html

The expression works for scale,and opacity on the shape layer but not on the Text layer.

I want the fill color to change from white to black when click I the text, but it doesn't.

Please help, the project depends on it. :cry:


This is the expression:

// Fill color of TEXT manipulated with control layer "Drag Me"
// expression Applied to fill color parameter of TEXT
// Point1 is TEXT layer, point2 is control layer

point1=this_layer.position;
point2=this_comp.layer("Drag Me").position;

// Find the vector between the 2 points

delta=sub(point1, point2);

// Now find the length

distance=length(delta);

//Use linear() to remap distance to range of 40 to 0
//Color is a 4 dimension array like [red,blue,green,alpha]

linear(distance, 0, 80, [0,0,01], [1,1,1,1]);


Any help is greatly appreciated!
User avatar
lloydalvarez
Enhancement master
Posts: 460
Joined: June 17th, 2004, 9:27 am
Location: New York City, NY
Contact:

i am not sure that linear works with arrays.. so try this instead:

Code: Select all

// Fill color of TEXT manipulated with control layer "Drag Me"
// expression Applied to fill color parameter of TEXT
// Point1 is TEXT layer, point2 is control layer

point1=this_layer.position;
point2=this_comp.layer("Drag Me").position;

// Find the vector between the 2 points

delta=sub(point1, point2);

// Now find the length

distance=length(delta);

//Use linear() to remap distance to range of 40 to 0 
//Color is a 4 dimension array like [red,blue,green,alpha]
c=linear(distance, 0, 80, 0, 1);
[c,c,c,1]
-Lloyd
Dan Ebberts
Posts: 320
Joined: June 26th, 2004, 10:01 am
Location: Folsom, CA
Contact:

You just need to fix the typo in your last line, like this:

linear(distance, 0, 80, [0,0,0,1], [1,1,1,1]);


Dan
charliebrown
Posts: 8
Joined: June 10th, 2008, 9:16 am

Thanks for the reply. Tried the suggestion, but still no change.
User avatar
lloydalvarez
Enhancement master
Posts: 460
Joined: June 17th, 2004, 9:27 am
Location: New York City, NY
Contact:

where are you applying this expression? It should be applied to the color property of a Fill effect.

-Lloyd
charliebrown
Posts: 8
Joined: June 10th, 2008, 9:16 am

Here is the project file sample. what am I doing wrong?

http://www.simulationbox.com/wp-content ... nd/GUI.aep
Last edited by charliebrown on June 23rd, 2008, 4:54 pm, edited 1 time in total.
User avatar
lloydalvarez
Enhancement master
Posts: 460
Joined: June 17th, 2004, 9:27 am
Location: New York City, NY
Contact:

no project attached :(
charliebrown
Posts: 8
Joined: June 10th, 2008, 9:16 am

User avatar
lloydalvarez
Enhancement master
Posts: 460
Joined: June 17th, 2004, 9:27 am
Location: New York City, NY
Contact:

The problem is that you have your text layer parented to the rectangle layer so the position in this_layer.position is no longer in world space and therefore the length calculation is not correct. Since the trigger area is the rectangle, simply use it's position for the length calculation:

Code: Select all

// Point1 is current layer, point2 is control layer
point1=this_comp.layer("Rectangle_1").position;
point2=this_comp.layer("Drag Me 2").position;

// Find the vector between the 2 points
delta=sub(point1, point2);

// Now find the length
distance=length(delta)*6;

//Use linear() to remap distance to range of 40 to 0
linear(distance, 39.5, 40, [1,1,1, 0], [0,0,0,0]);
-Lloyd
charliebrown
Posts: 8
Joined: June 10th, 2008, 9:16 am

Lloyd, I must say: YOU...ARE...THE..MAN :wink:

You ROCK and RULE and ROLL !!! 8)

You found the solution. It is Purfect.

Thank you.

What do I need to do, to be able to duplicate the text layer and parent it to another rectangle without having to tinkle with the expression.

seems like if I do it now, I would have to go in and manually change the layer referenced in point1.

I want to create a cascade.

Thanks Llyod.
Last edited by charliebrown on June 23rd, 2008, 8:39 pm, edited 1 time in total.
charliebrown
Posts: 8
Joined: June 10th, 2008, 9:16 am

Lloyd, never mind by last post. I figured it out.

instead of giving point1 an actual name, I index it. (index + 1)
now I can duplicate it as many times and stack it.

so here the final expression:


// Point1 is current layer, point2 is control layer
point1=this_comp.layer("index + 1").position;
point2=this_comp.layer("Drag Me 2").position;

// Find the vector between the 2 points
delta=sub(point1, point2);

// Now find the length
distance=length(delta)*6;

//Use linear() to remap distance to range of 40 to 0
linear(distance, 39.5, 40, [1,1,1, 0], [0,0,0,0]);


Thank you Lloyd.
You're Grrreaaat!!!
User avatar
lloydalvarez
Enhancement master
Posts: 460
Joined: June 17th, 2004, 9:27 am
Location: New York City, NY
Contact:

That will work, but don't put and quotes around index +1:

Code: Select all

point1=this_comp.layer(index + 1).position;

One other thing I forgot to point out is that you are using some old syntax that might get phased out in future versions of AE. this_comp is now thisComp and this_layer.postion can simply be written as position.

-Lloyd
charliebrown
Posts: 8
Joined: June 10th, 2008, 9:16 am

Thanks Lloyd. I concur. :D
Post Reply