سؤال

I have a weather map template. And I'd like the moon icon to change automaticaly to full moon on certain dates.

So I need expression to check if today's date is part of some array or list or how is it called.

So I made one text layer, that displays current date

D = new Date(Date(0));
D.getDate() + "/" + (D.getMonth()+1) + "/" + D.getFullYear()

And I applyed this expression to opacity of the full moon icon

d = thisComp.layer("theDateLayer").text.sourceText;
vis = transform.opacity;
year = 2013;
fullM = ["27/3","25/4","25/5","23/6","22/7","21/8","19/9","19/10","17/11","17/12"];

if (d == fullM"/year")
vis = 100
else
vis = 0;

But its not working. I guess its because the date would have to be same as the whole array. I need to write that I only need any item thats in it. How?

Thanks

هل كانت مفيدة؟

المحلول

What are you trying to accomplish with the statement d == fullM"/year"? I think you might be trying to do something like this:

d = thisComp.layer("asdf").text.sourceText;
year = "2013";
fullM = ["27/3","25/4","25/5","23/6","22/7","21/8","19/9","19/10","17/11","17/12"];


for(var i = 0; i < fullM.length; i++) {
    if(d == fullM[i] +"/"+ year) {
        100;
        break;
    } else {
        0;
        break;
    }
}

...assuming that the sourceText of that layer is a string that will be equivalent. My code uses a for loop to traverse the fullM array. You should read up on JavaScript for loops.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top