Skip to main content
maciejg29604886
Participant
March 9, 2022
Question

Can I control the scale property of a layer with a value of source text from a different layer

  • March 9, 2022
  • 1 reply
  • 218 views

Hi, I would like to scale a layer from its axis say from 0 to 100 using numerical text such as 0 - 100. 

Basically automate a bar graph values by setting the anchor at the bottom or rectangles and having some text on top links to nulls from paths, so when I wrote 20 in the text on top it would scale the rectangle to 20% scale and move the nulls up. but I also wanted to add the % after the text with +'%' but not sure how I can do that.

All I can manage so far is to use

comp('master').layer([index]).text.sourceText+'%'

which uses the text from 'master' comp and adds the % but id also like to use that value to control the scale of a rectangle in the comp as well, the rectangle is not in the master comp layer.

Any ideas? I dont mind it all being controlled from the same comp if its easier.

Thanks]

Mac

 

This topic has been closed for replies.

1 reply

Dan Ebberts
Community Expert
Community Expert
March 9, 2022

Something like this should work, as long as the scale value is the first part of the text:

y = parseFloat(comp('master').layer([index]).text.sourceText);
[value[0],y]
maciejg29604886
Participant
March 10, 2022

This worked perfectly, Thank you so much!