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

What is Framer? Join the Community
Return to index
Jacek Stryk
Posted Jun 20 - Read on Facebook

Can I use variables to access imported Sketch layers? Example:

Artboard 1
Layer A
Layer B


sketch.layerArray[layerIndex].style.outline = "1px solid red"

Currently, when I try to do that I get a TypeError: undefined is not an object (evaulating 'sketch.layerArray[]

When I'm trying to do is to dynamically change layer's outline when users press a key.


Sergey Voronov

layerArray is not sketch object, so u can't call it like that . also dont use "" for adding layers into array,cause array will just contay strings

Sergey Voronov

layerArray=[Layer_A,Layer_B] print layerArray[layerIndex]

Jacek Stryk

Thanks, indeed the array need to be holding objects i.e. Layer_A not strings "Layer_A". It's always good to watch for the parenthesis :)

Read the entire post on Facebook