using values of an "expressioned" property as an input

Explorer ,
Mar 24, 2022 Mar 24, 2022

Copy link to clipboard

Copied

i tried manipulate one layer's property by another layer that is being manipulated too and it didn't work.

I'll explain:

I had layerA that it's position value is being manipulated by an expression, and I wanted layerB opacity to turn 100% on if layerA position[0] is greater than 0. It didn't work. but when I turned off layerA expression and changed it's position manually, it did work.

I have the impression that layerB opacity expression is looking at the original value and not at the manipulated one.

Is it correct? is there any way making the expression look at the manipulated value?

TOPICS
Expressions , How to

Views

159

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 24, 2022 Mar 24, 2022

Copy link to clipboard

Copied

An expression on one property only has access to the post-expression value of another property, so I suspect you're misinterpreting what's going on. What do the two expressions look like?

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Mar 24, 2022 Mar 24, 2022

Copy link to clipboard

Copied

The expression on layerB Position is an array of values which is picked by the numbers on another layers' markers.

 

(It might sound familiar because you took a big part in building this template I'm working on, solving all the riddles I couldn't decipher 😅).

 

 

This is the full expression both layers have on their position:

m = comp("ASA_LL_sky_UI").layer("Click controller B").marker.key(2).comment;


const cm = comp("ASA_LL_sky_UI").layer("Click controller B").marker;
const catM = comp("ASA_LL_sky_UI").layer("Sky CAT controller").marker;
let latestMarkerIndex = 0;


if (catM.numKeys > 0) {
 latestMarkerIndex = cm.nearestKey(time).index;


 if (cm.key(latestMarkerIndex).time > time) {
latestMarkerIndex--;
 }
}
let outputText = "";


if (latestMarkerIndex > 0) {
 const latestMarker = cm.key(latestMarkerIndex);
 outputText = latestMarker.comment;
};

menus =  comp("ASA_LL_sky_UI").layer("Sky CAT controller").effect(2)("Menu").value;
yVals = [371,634,896,1157,1416,1684,1950,2208,2470,2730,2995,3254,3515,3781,4038];
m = outputText-1;
y = yVals[menus-1];
result = [
	[ 159.0632 , y ],
	[ 349.0632 , y ],
	[ 540.0632 , y ],
	[ 731.0632 , y ],
	[ 920.0632 , y ]
];

result[m];

 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 24, 2022 Mar 24, 2022

Copy link to clipboard

Copied

What's layer B's opacity expression?

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Mar 25, 2022 Mar 25, 2022

Copy link to clipboard

Copied

cB = this comp.layer("B").transform.position[0];

cB > -120 ? 100 : 0;

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 25, 2022 Mar 25, 2022

Copy link to clipboard

Copied

I'm confused. In your original post you mentioned that layer B's opacity expression was looking at layer A's position, but the opacity expression you just posted doesn't have a reference to layer A.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Mar 25, 2022 Mar 25, 2022

Copy link to clipboard

Copied

Yep, you are right.

I wrote it the opposite way on my first post...

So according to the explanation on the first post, it suppose to be written that way:

 

cA = this comp.layer("A").transform.position[0];

 

cA > -120 ? 100 : 0;

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 25, 2022 Mar 25, 2022

Copy link to clipboard

Copied

At this point I'm afraid it would be hard to diagnose the issue without seeing the actual project file.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Mar 27, 2022 Mar 27, 2022

Copy link to clipboard

Copied

So it seems like I have found a solution.

I wrote in the opacity property the same code as in the position, and added the if else statement at the end of it:

(in this code, layer A's opacity is looking at layer B's position to know when to turn off. when layer B's position[0] > -120, layer A's opacity will turn 0%)

 

m = comp("ASA_LL_sky_UI").layer("Click controller B").marker.key(2).comment;


const cm = comp("ASA_LL_sky_UI").layer("Click controller B").marker;
const catM = comp("ASA_LL_sky_UI").layer("Sky CAT controller").marker;
let latestMarkerIndex = 0;


if (catM.numKeys > 0) {
 latestMarkerIndex = cm.nearestKey(time).index;


 if (cm.key(latestMarkerIndex).time > time) {
latestMarkerIndex--;
 }
}
let outputText = "";


if (latestMarkerIndex > 0) {
 const latestMarker = cm.key(latestMarkerIndex);
 outputText = latestMarker.comment;
};

menus =  comp("ASA_LL_sky_UI").layer("Sky CAT controller").effect(2)("Menu").value;
yVals = [371,634,896,1157,1416,1684,1950,2208,2470,2730,2995,3254,3515,3781,4038];
m = outputText-1;
y = yVals[menus-1];
result = [
	[ 159.0632 , y ],
	[ 349.0632 , y ],
	[ 540.0632 , y ],
	[ 731.0632 , y ],
	[ 920.0632 , y ]
];

result[m];

cB = thisComp.layer("B").transform.position[0];
cB > -120 ? "0" : "100";

 

 

 

I hope it won't cause troubles anyhow later or.. 

But I'm still curious to know what prevented this code from working...

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 27, 2022 Mar 27, 2022

Copy link to clipboard

Copied

In that configuration, only the last two lines have any effect on the outcome, so if it works like that, you should be able to get rid of all the code above those two lines.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Mar 27, 2022 Mar 27, 2022

Copy link to clipboard

Copied

Ghost layer?!

This is so weird. It still didn't work when I deleted all the code above the last two lines, so I tried rendering the frame and the layer disappeared from the rendered image

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Mar 27, 2022 Mar 27, 2022

Copy link to clipboard

Copied

LATEST

Sorry, I rendered it once more and it appears again..

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines