Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

What is the scope of variables declared/assigned in expressions?

Enthusiast ,
Apr 28, 2019 Apr 28, 2019

Reason for asking, I have these calculations that have very long links to other attributes in the composition, mostly slider controls like for eg:

time < thisComp.layer("[CONTROLS]").effect("Total Animation Period")("Slider") - thisComp.layer("[CONTROLS]").effect("bkgd fade period")("Slider")? clamp(transform.opacity * time / thisComp.layer("[CONTROLS]").effect("bkgd fade period")("Slider"), 0, value) : clamp(transform.opacity * (thisComp.layer("[CONTROLS]").effect("Total Animation Period")("Slider") - time) / thisComp.layer("[CONTROLS]").effect("bkgd fade period")("Slider"), 0, value)

This could be reduced to something much easier to read, and more importantly save me a tonne of quickpicking/typing if I could set global variables to the relevant composition settings and values at various indexes (preprogrammed states that can be selected between by user or expression logic) (at least global in the scope of the AE comp containing the expression).

it would look like this:

time < totalTime - bkgdFadePeriod ? clamp(this * time / bkgdFadePeriod, value) : clamp(totalTime - time/bkgdFadePeriod)

Can think of lots of advantages to this kind of referencing, any downsides? I'll suck it and see and report back.

TOPICS
Expressions
1.2K
Translate
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 1 Correct answer

LEGEND , Apr 28, 2019 Apr 28, 2019

There is no such thing as "scope". An expression only evaluates inside its property stream and that's it. It's totally ignorant of the outside world unless you reference external property streams and those again only return values, not actual variables, functions or whatever in the programming sense.

Mylenium

Translate
LEGEND ,
Apr 28, 2019 Apr 28, 2019

There is no such thing as "scope". An expression only evaluates inside its property stream and that's it. It's totally ignorant of the outside world unless you reference external property streams and those again only return values, not actual variables, functions or whatever in the programming sense.

Mylenium

Translate
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
Enthusiast ,
Apr 28, 2019 Apr 28, 2019
LATEST

Thanks, so I wasn't going mad. Copy and pasting my script intros with variable assignments is best I can think of for now… I saw a tutorial where a guy had a script that changed the colour of a circle object by an expression on the Hue value of a HSL Colorise effect and the expression script tested the distance to five other circles and adjusted hue according to distance to nearest object.

He wanted the script to run on the other five circles but rather than cutting and pasting the expression script, he did something else, which I forget now.

Translate
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