Welcome Dialog

Welcome to the Community!

We have a brand new look! Take a tour with us and explore the latest updates on Adobe Support Community.


Parent Scale property to slider

New Here ,
May 11, 2021 May 11, 2021

Copy link to clipboard

Copied

is it possible to make a slider that controls scale property 

slider.              = 0.    // when slider hits value " 0 "

scale property = 0.   // transform.scale property also hits value " 0 "

 

slider                = 100.  // but when slider hits value " 100 "

scale property  = 45.    // scale property of layer hits actual/user-Inout Value

TOPICS
Error or problem, Expressions, How to

Views

666

Likes

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 2 Correct answers

Adobe Community Professional , May 11, 2021 May 11, 2021
Oops! I made a basic error, sorry about that. The Scale property is an array (it has both an X and Y dimension, even if you want them to be the same thing). So the linear() function I gave you is telling the Scale property to go from "0" to "45" but that's only half the value a Scale property needs (hence the error saying the 'result must be of dimension 2'). Also, you don't want to put the slider inside the brackets, and you don't need to make your scaleController an array. Your code should loo...

Likes

Translate

Translate
Adobe Community Professional , May 11, 2021 May 11, 2021
If I'm understanding what you want, you have a couple options here: 1) You can replace the hard-coded [45, 45] with a variable so you don't have to enter the value twice inside of the linear() function. This would look like this: const scaleController= effect("Slider Control")("Slider"); const newScale = 58; linear( scaleController, 0, 100, [0,0] , [newScale, newScale] ); 2) You can skip the extra step all together and manually set the scale of the new shape to your desired final size, then ...

Likes

Translate

Translate
Adobe Community Professional ,
May 11, 2021 May 11, 2021

Copy link to clipboard

Copied

Yup! You can do this with a slider and an expression on your Scale property.

 

const scaleController= [pick whip to slider];

linear( scaleController, 0, 100, 0, 45);

The first line is declaring the slider as a variable, but the second line uses the linear() function. This lets you map one set of values to another, so it's simply saying:

 

As the value of the scaleController goes from 0 to 100, change the value of the property this code is applied to (Scale) from 0 to 45.

Likes

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
New Here ,
May 11, 2021 May 11, 2021

Copy link to clipboard

Copied

it says 

 

const scaleController= [effect("Slider Control")("Slider")]; l 

expression result must of dimension 2 not 1 

inear( scaleController, 0, 100, 0, 45);

 

const scaleController= [effect("Slider Control")("Slider"),effect("Slider Control 2")("Slider")];

linear( scaleController, 0, 100, 0, 45);

argument 1 to linear() must be scalar

Likes

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
New Here ,
May 11, 2021 May 11, 2021

Copy link to clipboard

Copied

Hi 

@davidarbor 

 

I tried using the expression you mentioned but facing errors

 

it says

const scaleController= [effect("Slider Control")("Slider")]; l 

Error: expression result must of dimension 2 not 1 

inear( scaleController, 0, 100, 0, 45);

 

const scaleController= [effect("Slider Control")("Slider"),effect("Slider Control 2")("Slider")];

linear( scaleController, 0, 100, 0, 45);

Error: argument 1 to linear() must be scalar

Likes

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
Adobe Community Professional ,
May 11, 2021 May 11, 2021

Copy link to clipboard

Copied

Oops! I made a basic error, sorry about that. The Scale property is an array (it has both an X and Y dimension, even if you want them to be the same thing). So the linear() function I gave you is telling the Scale property to go from "0" to "45" but that's only half the value a Scale property needs (hence the error saying the 'result must be of dimension 2').

Also, you don't want to put the slider inside the brackets, and you don't need to make your scaleController an array. Your code should look like this.

 

const scaleController= effect("Slider Control")("Slider");

linear( scaleController, 0, 100, [0,0] , [45,45] );

 

If you get a new error saying that "scaleController" has been redeclared, make sure you're using the JavaScript expression engine as opposed to the old Legacy ExtendScript engine. You can check this from File > Project Settings > Expression. 

 

Likes

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
New Here ,
May 11, 2021 May 11, 2021

Copy link to clipboard

Copied

lets say if I put a random value instead of 45 then?

like making it a motion preset

where 

I draw a shape with any scale value and link that shape's scale property to slider control using expression

Likes

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
Adobe Community Professional ,
May 11, 2021 May 11, 2021

Copy link to clipboard

Copied

If I'm understanding what you want, you have a couple options here:

 

1) You can replace the hard-coded [45, 45] with a variable so you don't have to enter the value twice inside of the linear() function. This would look like this:

const scaleController= effect("Slider Control")("Slider");

const newScale = 58;

linear( scaleController, 0, 100, [0,0] , [newScale, newScale] );

2) You can skip the extra step all together and manually set the scale of the new shape to your desired final size, then you can apply this expression to the property.

const scaleController= effect("Slider Control")("Slider");

linear( scaleController, 0, 100, 0 , value);

value means the pre-expression value, and while the property value will get overwritten by an expression, the original value still exists behind it. So the function is now saying "as the slider goes from 0 to 100, go from 0 to whatever my pre-expression value is on this property. This has the benefit of being dynamic because you can still scrub the property, manually type a value, or even keyframe the property, even though the expression is applied. Also, you only have to write the one word instead of typing out an array because value already represents an array on a Scale property.

 

You'll also notice that you can actually write "0" instead of "[0, 0]" as the fourth argument in any of the instances here. What's great about this is that it makes this expression even more modular—it means that you can apply this same expression to Opacity or Rotation, which are both scalar (a single value) vs an array without having to modify the code to match the property type.

Likes

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
New Here ,
May 11, 2021 May 11, 2021

Copy link to clipboard

Copied

Thankyou for helping me out

@davidarbor 

it worked

Likes

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
Adobe Community Professional ,
May 11, 2021 May 11, 2021

Copy link to clipboard

Copied

Great, glad it helped!

Likes

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
Adobe Community Professional ,
May 11, 2021 May 11, 2021

Copy link to clipboard

Copied

LATEST

I would take the current value of the property you want to control with the slider and use that as the starting value for a linear or ease expression. If the Effects Control Slider named "Scale Control" and was on the same layer you are trying to animate the expression would look like this:

ctrl = effect("Scale Slider")("Slider");
ease(ctrl, 0, 100, value, [100, 100]);

Now any value you set for scale would be the starting value when the slider was at 0 and the scale would be [100, 100] when the slider was at 100. You could even animate the original scale by setting keyframes and then override the keyframes with the slider. I chose ease instead of Linear because I usually ease scale keyframes and this saves me a step. Using the original scale "value" also eliminates the need to edit the expression so the layer is easier to animate.

Likes

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