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

What is Framer? Join the Community
Return to index
Dmitry Sholkov
Posted May 16 - Read on Facebook

Hey guys, can anyone explain what I'm doing wrong?

I need a function that creates copy of a layer. On a click event outside the function i want to be able to destroy created copy. But because copy is technically inside function Framer couldn't find layer that I'm referring to.

http://share.framerjs.com/506vzi0hb3p7/

3 Comments

Joshua Tucker

Hey Dmitry! You are creating layerB inside of myFunction, which means that variable is local to that function, not available globally (or within the click function). Easy fix would be to create the layerB variable outside of the function like so:

layerB = null

Good place to define this would be underneath layerA.

Then when you create the layer with that variable, it's available globally/within scope of everything.

Dmitry Sholkov

Awesome! Thanks Joshua!

Edwin Van Rijkom

This approach could also read back nicely:

Read the entire post on Facebook