Page 1 of 1

Interactive Click

Posted: June 23rd, 2008, 10:46 am
by charliebrown
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!

Re: Interactive Click

Posted: June 23rd, 2008, 12:47 pm
by lloydalvarez
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

Re: Interactive Click

Posted: June 23rd, 2008, 1:50 pm
by Dan Ebberts
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

Re: Interactive Click

Posted: June 23rd, 2008, 2:54 pm
by charliebrown
Thanks for the reply. Tried the suggestion, but still no change.

Re: Interactive Click

Posted: June 23rd, 2008, 3:59 pm
by lloydalvarez
where are you applying this expression? It should be applied to the color property of a Fill effect.

-Lloyd

Re: Interactive Click

Posted: June 23rd, 2008, 4:31 pm
by charliebrown
Here is the project file sample. what am I doing wrong?

http://www.simulationbox.com/wp-content ... nd/GUI.aep

Re: Interactive Click

Posted: June 23rd, 2008, 4:47 pm
by lloydalvarez
no project attached :(

Re: Interactive Click

Posted: June 23rd, 2008, 4:54 pm
by charliebrown

Re: Interactive Click

Posted: June 23rd, 2008, 7:37 pm
by lloydalvarez
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

Re: Interactive Click

Posted: June 23rd, 2008, 8:25 pm
by charliebrown
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.

Re: Interactive Click

Posted: June 23rd, 2008, 8:37 pm
by charliebrown
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!!!

Re: Interactive Click

Posted: June 24th, 2008, 4:37 am
by lloydalvarez
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

Re: Interactive Click

Posted: June 24th, 2008, 5:06 am
by charliebrown
Thanks Lloyd. I concur. :D