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

Expression error, beating my head

Explorer ,
Aug 10, 2021 Aug 10, 2021

In an expression I'm trying to access a layer by index based on a calculation:

laynum = (index-1) - Math.floor(time);
craplayer = thisComp.layer(laynum);

but I keep getting the error "layer index -1 out of range" on that second line -- yet if I return laynum in my expression to look at the value, it's 3.0 which is correct in my case (expression is on a numeric property on layer 4, while sitting on frame 0 of the comp.)

 

If I do:

laynum = 3.0;

instead of my calculation, it works fine. I'm just not seeing what the difference is, why this isn't working. I'm using the Javascript expression engine, not the old ExtendScript.

TOPICS
Error or problem , Expressions
578
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
Explorer ,
Aug 10, 2021 Aug 10, 2021

Well, nevermind, I guess.

After messing around more trying to figure out what the fail was, it's inexplicably started working without changing the substance of anything.

 

I'd delete this thread but apparently we're not allowed.

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
Community Expert ,
Aug 10, 2021 Aug 10, 2021
LATEST

With your expression on layer 4, when time gets to 3 seconds laynum will be 0 which will make layer(laynum) generate that error.

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