If statement in Expression that refuses to cooperate.
Posted: September 25th, 2008, 9:33 am
Ooh... Guys... Pulling my hair out over here. I'm stuck at something that SHOULD work and that really is no hard thing at all.
The scenario is that I animate a null that have several other layers linked (with expression) to it. And then those individual layers reaches a certain Y-value I want to "kill" them by setting the opacity to 0. But I want to do that on the frame after they reach this value. And it seems like the valueAtTime only works in scripts and not in expressions. Sooo... I thought that I just bounce a "control value" in a slider or so to get the behavior I want. Should be an easy thing but no matter how I do it I can get it to work. So starting to think that there is something funny going on here that I don't know about.
This is the first expression I tried:
But it's a no go. For some reason it keeps going back into the if(opacityBounce < 2) even though opacityBounce is 2. So it never sets the slider value (effect("Opacity Fix Bounce")(1).value) to 3.
Soo... After slamming my head to the desk a couple of hours and trying variations of that expression i tried something like:
But it still never sets the slider to 3. And I can not understand why. When writing all these I got a bit uncertain to if it should be two "=" when checking the value in opacityBounce. LIke:
or
I was almost 100% certain that it should be "==". But that's a no go in all cases. Which I find odd? Have I missed something fundamental in AE? Or what's going on here. I'm going so nuts that I don't know what to do or where to go or what to break. =(
Or is there an easier way to from Expressions set a "valueAtTime"...?
The scenario is that I animate a null that have several other layers linked (with expression) to it. And then those individual layers reaches a certain Y-value I want to "kill" them by setting the opacity to 0. But I want to do that on the frame after they reach this value. And it seems like the valueAtTime only works in scripts and not in expressions. Sooo... I thought that I just bounce a "control value" in a slider or so to get the behavior I want. Should be an easy thing but no matter how I do it I can get it to work. So starting to think that there is something funny going on here that I don't know about.
This is the first expression I tried:
Code: Select all
//Variables
//At what yposition do we "kill" the layer?
ykill = 410;
opacityBounce = effect("Opacity Fix Bounce")(1).value;
//opacityBounce = Math.floor(opacityBounce);
//variable for storing the Y-position of the layer
ypos = transform.position[1];
//If we have reached the killframe or are outside the frame
if( (ypos <= ykill) || (ypos > 600) ){
if(opacityBounce < 2){
effect("Opacity Fix Bounce")(1).value = 2;
}
else if (opacityBounce == 2){
effect("Opacity Fix Bounce")(1).value = 3;
}
}
//Text visible
else{
effect("Opacity Fix Bounce")(1).value = 1;
}
Soo... After slamming my head to the desk a couple of hours and trying variations of that expression i tried something like:
Code: Select all
//Variables
//At what yposition do we "kill" the layer?
ykill = 410;
opacityBounce = effect("Opacity Fix Bounce")(1).value;
//variable for storing the Y-position of the layer
ypos = transform.position[1];
//If we have reached the killframe or are outside the frame
if( ( (ypos <= ykill) || (ypos > 600) ) && (opacityBounce = 1) ){
effect("Opacity Fix Bounce")(1).value = 2;
}
else if( ( (ypos <= ykill) || (ypos > 600) ) && (opacityBounce = 2) ){
effect("Opacity Fix Bounce")(1).value = 3;
}
//Text visible
else{
effect("Opacity Fix Bounce")(1).value = 1;
}
Code: Select all
if(opacityBounce = 2){
Code: Select all
if(opacityBounce == 2){
Or is there an easier way to from Expressions set a "valueAtTime"...?