Jump to content
Sign in to follow this  
cabecinha

AE Expression counter number between brackets.

Recommended Posts

i couldnt get RVA's method to work, but i could be doing it wrong..


it gave me "After Effects Warning: invalid numeric result (divide by zero?) Expression disabled"




I did it another way, but it probaby isnt clean, i had 4 text layers. 2 with the brackets, and one with the expression tied to the slider.


i hid those, and created a 4th text layer parenting the source text to each of the other 3 layers source text and that worked for me


Share this post


Link to post
Share on other sites

I already had tried the RVA8 version and encountered the exact same problem.

Your way Encity definitely work, not the cleanest like you said but does the job.

Maybe someone can tell a simple way for the future.

Appreciate the help. Thanks.

Edited by cabecinha

Share this post


Link to post
Share on other sites

This took me a few minutes, but this should work.

 

(The slider needs to be converted to a string. You can't add integers to strings. So the number has to be converted. Hence "toString")

 

 

num = thisComp.layer("Null 1").effect("Slider Control")("Slider");

n=num[0].toString();

brack1 = "[";

brack2 = "]";

brack1 + n + brack2

 

 

 

Can someone fill me in on why a single value slider needs an index? ( [0] ) ? Mylenium?

 

 

P.S. If you only want integers, replace the second line with this:

 

n=Math.round(num[0].toString());

Edited by throb36

Share this post


Link to post
Share on other sites

Huh, yep, that sure doesn't work! Throb36 is exactly right - the expression control needed to be a string. However I was able to get it to work like this too:

 

 

n = Math.round(effect("Slider Control")("Slider"))

"[" + n + "]"

 

For some reason just using Math.round() made it ok, without using the toString() function. I can't see why just using the math function would make any difference other than some internal type conversion. Or maybe it's just a bug. Learn something new every day I guess.

 

R

 

 

edit: apparently also this work:

 

 

n = (effect("Slider Control")("Slider"))+0

"[" + n + "]"

Edited by RVA8

Share this post


Link to post
Share on other sites

I just ran into this issue recently as well...

 

The solution I came up with was to grab the "value" from the slider, not just the slider "object":

"[" + effect("Slider Control")("Slider").value + "]";
Edited by DrVrtigo

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...