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

What is Framer? Join the Community
Return to index
Patrick McLean
Posted Mar 09 - Read on Facebook

Hi,

I’m duplicating 2 different layers X number of times with X different states for each layer using a for loop.

I’d like to switch states for two layers at the same time on an event like this:

product.on Events.MouseOver, (event, product, productName) ->
product.states.switch("hover")
productName.states.switch("hover")

But I get “undefined is not an object” in reference to productName on the event.

I think there’s some core concept I’m missing. Any ideas?

4 Comments

George Kedenburg III

yeah, .on events don't work this way... could you share a bit more of your code? screenshot is fine

Jordan Robert Dobson

Mainly you can't define the arguments that get passed in, you can only name them. The first will always be the event object the second will be the layer that fired the event.

So essentially what you are doing is replacing, in the scope of this event's function, what product and productName are equal to... So leave that alone there.

Johannes Eckert

what I'd do is setting up the relationship of those layers when you create them, such as "layerA.relatedLayer = layerB", so you can use relatedLayer in your events on layerA: http://share.framerjs.com/zv9q5xlobtfe/

Patrick McLean

thanks so much for the detailed replies everybody. problem solved on my end. would any of you by any chance have links to documentation i could read to expand my understanding on this stuff? i don't quite have the language to describe the scenario so it's hard finding more info on the web.

Read the entire post on Facebook