• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

else if statement with multiple conditions - I'm confused

Explorer ,
Mar 22, 2022 Mar 22, 2022

Copy link to clipboard

Copied

Im struggling with an else if statement.

I have 17 text layers.
3 drop menus (drA, drB, drC) with 15 objects in each.
and 3 markers (A, B, C) on a layer.

I want every text layer the be bold only when the right condition is met.
for example,
if drA == 1
and the time is between markers A and B,
layer 1 will be bold.
and when time goes beyond marker B, layer 1 will become regular again, unless drB is set to 1 too.
same goes for the rest of the text layers.


i wrote down this expression and I think the conditions are not mutually exclusive, because when time goes beyond the first marker, the layer becomes bold and stays.
anyway is doesn't work.

this is the expression:

 

dr1 = comp("ASA_LL_sky_UI").layer("Sky CAT controller").effect("Sky A")("Menu").value;
dr2 = comp("ASA_LL_sky_UI").layer("Sky CAT controller").effect("Sky B")("Menu").value;
dr3 = comp("ASA_LL_sky_UI").layer("Sky CAT controller").effect("Sky C")("Menu").value;

b = text.sourceText.style.setFont("Avenir-Black");
r = text.sourceText.style.setFont("Avenir-Medium");


catM = comp("ASA_LL_sky_UI").layer("Sky CAT controller").marker;
menus =  comp("ASA_LL_sky_UI").layer("Sky CAT controller").effect(1)("Menu").value;


cA = time > catM.key(1).time && time < catM.key(2).time;
cB = time > catM.key(2).time && time < catM.key(3).time;
cC = time > catM.key(3).time;


if 		(dr1 == index-6 && cA) b;
else if (dr1 == index-6 && cB) b;
else if (dr1 == index-6 && cC) b;

else if (dr2 == index-6 && cA) b;
else if (dr2 == index-6 && cB) b;
else if (dr2 == index-6 && cC) b;

else if (dr3 == index-6 && cA) b;
else if (dr3 == index-6 && cB) b;
else if (dr3 == index-6 && cC)
{b} else {r};
TOPICS
Expressions , How to

Views

679

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

correct answers 1 Correct answer

Community Expert , Mar 22, 2022 Mar 22, 2022

I'd do it like this (I think):

dr1 = comp("ASA_LL_sky_UI").layer("Sky CAT controller").effect("Sky A")("Menu").value;
dr2 = comp("ASA_LL_sky_UI").layer("Sky CAT controller").effect("Sky B")("Menu").value;
dr3 = comp("ASA_LL_sky_UI").layer("Sky CAT controller").effect("Sky C")("Menu").value;

b = "Avenir-Black";
r = "Avenir-Medium";

catM = comp("ASA_LL_sky_UI").layer("Sky CAT controller").marker;

if (time < catM.key(1).time){
  f = r;
}else if (time < catM.key(2).time){
  f = dr1 == index-6 ? b 
...

Votes

Translate

Translate
Community Expert ,
Mar 22, 2022 Mar 22, 2022

Copy link to clipboard

Copied

I'd do it like this (I think):

dr1 = comp("ASA_LL_sky_UI").layer("Sky CAT controller").effect("Sky A")("Menu").value;
dr2 = comp("ASA_LL_sky_UI").layer("Sky CAT controller").effect("Sky B")("Menu").value;
dr3 = comp("ASA_LL_sky_UI").layer("Sky CAT controller").effect("Sky C")("Menu").value;

b = "Avenir-Black";
r = "Avenir-Medium";

catM = comp("ASA_LL_sky_UI").layer("Sky CAT controller").marker;

if (time < catM.key(1).time){
  f = r;
}else if (time < catM.key(2).time){
  f = dr1 == index-6 ? b : r;
}else if (time < catM.key(3).time){
  f = dr2 == index-6 ? b : r;
}else{
  f = dr3 == index-6 ? b : r;
}
text.sourceText.style.setFont(f)

Votes

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 23, 2022 Mar 23, 2022

Copy link to clipboard

Copied

LATEST

Thats awesome! and so much simpler then what I tried to do...

I learn a lot from it. Thanks you!

Votes

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