Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Expression to control “0% ~ 100%” Using “Slider”

  • Dan Ebberts

    April 10, 2012 at 7:13 pm

    I’m not sure what you’re asking. You can add a Slider Control and then link it to some property you want to control via an expression–is that what you mean?

    Dan

  • Yasush Azush

    April 10, 2012 at 7:25 pm

    Hi Dan,

    Thanks for the quick reply.

    I have a slider with min=0, max=100. For example when the slider is showing 43, I need the text layer to show 43%.

    Is this possible?

    Thanks

  • Dan Ebberts

    April 10, 2012 at 8:38 pm

    Ah, OK–something like this:

    s = thisComp.layer(“Slider Layer”).effect(“Slider Control”)(“Slider”).value;
    s + “%”

    If you want to limit the number of decimal places to 2, for example, change the last line to this:

    s.toFixed(2) + “%”

    Or to this, if you just want whole numbers:

    Math.round(s) + “%”

    Dan

  • Yasush Azush

    April 11, 2012 at 4:03 am

    Cool i’m going to give it a try, but where should I apply the expression to? Should I apply a text effect first to the layer or something?

    Thanks

  • Yasush Azush

    April 11, 2012 at 4:18 am

    Exellent Dan,

    I had to source text of a text layer and just works amazing. I’ll try to post the final work here.

    Thanks

  • Yasush Azush

    April 11, 2012 at 5:22 am

    Hi Dan,
    My head pumped to a bigger wall I guess, It never came to my mind that what I was doing was wrong. I guess I should have explained things more clear…

    How it’s done:
    I am creating a Pie Chart which has 5 Item, each item has two controllers, Color and Percentage value. Now what I did was created 5 different comps for each item, and in each Comp I added a Radial Transition effect to a layer and used it as an alpha for a layer that represent the color and value(Slice) that should be relevant with the text percentage you mentioned earlier. Finally I connect the “Transition Completion” value of each item to the corresponding slider. Until here everything works well and I was happy like a baby.

    The Problem:
    Because the slices all start from the same place the percentage and the potation of each layer is not correct. See the link please. https://imageshack.us/photo/my-images/820/piechart.jpg/
    The only color that is correct in the image is the green color(40%)

    Is this do-able? I can tell it needs lots of codes and stuff.

    Thanks

  • Dan Ebberts

    April 11, 2012 at 3:45 pm

    I think instead of just linking the text to the value, for all but the first segment you need to subtract the previous value from the current one. For the second segment it would be value2- value1, for the third it would be value3 – value2, etc.

    Dan

  • Yasush Azush

    April 11, 2012 at 4:04 pm

    Nop! Doesn’t work that way.

    You know I’m trying to understand how to divide the circle into 5 colors(slices) first, Lets say ok I need 20 precent of red 54 precent of green and maybe the rest will be calculated automatically ..!

    I guess this is far from my knowledge.

  • Yasush Azush

    April 11, 2012 at 4:31 pm

    I thought you are referring to the sliders value. So how do I subtract the values than? I did something and it gives me value1=23% value2= -23%

    Below is the code

    Thanks

    s=comp(PieChart").layer("Settings").effect(("Pie Chart Settings")(11).value;
    s+"%";

  • Dan Ebberts

    April 11, 2012 at 4:49 pm

    I would guess it would look something like this:

    v1 = comp(PieChart”).layer(“Settings”).effect((“Pie Chart Settings”)(10).value;
    v2 = comp(PieChart”).layer(“Settings”).effect((“Pie Chart Settings”)(11).value;
    (v2-v1) +”%”;

    Dan

Page 1 of 2

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy