This is a read-only archive of the Framer Community on Facebook.

What is Framer? Join the Community
Return to index
Eldar Burnashev
Posted Aug 10 - Read on Facebook

[SOLVED] Hey! Having trouble with using "i" and variable names. Got error: "Reference error: Can't find variable: layer"


Álvaro Matías Göede Rivera

You must put all the variables in an array to occupy them.

Mike Johnson

When using the bracket syntax [] you are effectively calling properties on the object before them. So layer["i"] is the same as writing layer.i

Since layer does not exist, layer.i will throw an error. Putting them in an array works. If they are children of another layer like listItems you can use listItems.children as the array.

Brent Riddell

you probably could write it like this too:

window["layer#{i+1}"].width = initialWidth

Read the entire post on Facebook