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

What is Framer? Join the Community
Return to index
Marcus Gellermark
Posted Jun 12 - Read on Facebook

Is there a way to clear events on a layer?

I would like to have one button that can do different things depending on where in the prototype I am.

so ish like this:

button = new Layer
Blah blah

button.on Events.TouchEnd, ->
layerX.states.swich(Blah blah)

But later on I want the layer to only do this:

button.on Events.TouchEnd, ->
layerY.states.swich(Blah blah)

So can I somehow clear the events before adding the new one?


Jörg Lehmann

yes, you can use the "off" function to remove the event listener:

layerA.on(Events.Click, clickHandler), clickHandler)

Koen Bok

Protip: you also have .once to just do something one time.

Marcus Gellermark

I can't get the once to work, but I found a workaround and using swichInstant on the states so the solution is ugly but working.

button.once Events.TouchEnd, ->


button.once Events.TouchEnd, ->

Read the entire post on Facebook