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

What is Framer? Join the Community
Return to index
Anton Jarl
Posted Jun 17 - Read on Facebook

Hello. I just ran into a really simple problem, but I can't get it to work. I'm trying to access nested layers of my sketch-import but it just won't work. I'm trying to add click event to layers that a grandchildren of the top layers. Like sketchLayers -> subLayer1 -> subLayer2 -> subLayer3. What's the syntax? "sketchLayers.subLayer1.subLayer2.subLayer3.on Events.Click, ->" won't work. And I don't even now what to Google for the answer..

3 Comments

Andreas Wahlström

Hi! use subLayer3.on Events.click. Layer names are exported as a flat list. Make sure each layer name is unique in your export. Here's the help section on importing: http://framerjs.com/learn/import/

Anton Jarl

Really? Wow, thats simple. And it works. So there's no reason to access the layers through their parent layers since all layers are accessible globally? The only reason I'd want to access the parent label is if I want to perform some actions on all the children?

Chris Camargo

Well, there *might* be a reason you'd want to address a layer through its parent, but I only run into that when I'm looping over layers in a "for" loop, and my layers don't have unique names. When bringing in layers from Sketch, you can speak to each one directly since they should have unique names (but I don't use the importer often, so someone correct me if I'm wrong).

Read the entire post on Facebook