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

What is Framer? Join the Community
Return to index
Lorenzo Fernandez
Posted Nov 14 - Read on Facebook

I'm trying to assign a trigger event via for to a groupd of layers. But indipendently of which layer I over it only trigger the state to the first layer :

# 1. go through the folder and assign to each layer the states
# 2. on event go to the state

for layerId of lines.Ovals.subLayers
level=lines.Ovals.subLayers[layerId]

# add the different states
level.states.add
out:
scale:1
over:
scale:1.4

# add animation option
level.states.animationOptions =
curve: "spring"
curveOptions: {tension:500, friction:6,velocity:5}

# on mouse over do…
level.on Events.MouseOver, (event) ->
level.states.switch "over"

# on mouse out do…
level.on Events.MouseOut, (event) ->
level.states.switch "out"

11 Comments

Benjamin Den Boer

Is this what you're looking for, perhaps? https://www.facebook.com/video.php?v=673563246091484&set=o.385961098197634&type=2&theater

(Adding states to multiple layers)

Benjamin Den Boer

Otherwise, could you attach a your prototype or a new .framer document with your code?

Lorenzo Fernandez

i managed to assign the states, but i'm having a problem triggering the event. Also in the example you sent you assign the events manually not via FOR. Is there a way to do it programmatically?

Benjamin Den Boer

Sure, in the example I linked to you can simply add the events within the "for" loop, like this: https://www.facebook.com/groups/framerjs/permalink/588938307899911/?comment_id=589386771188398&offset=0&total_comments=5

Andreas Mitschke

How is layerID declared and what's the superLayer ?

Don't see something wrong except what's happening before and I wouldn't fill a variable instead use "this", but without the stuff before this, can't help.

Lorenzo Fernandez

Benjamin Den Boer in you example (if i understand correctly) you assign the event manually
"layerA.on Events.Click, ->
this.states.next("one","two")"

Cant you do something like
layers.on Events.Click, ->
this.states.next("one","two")

Lorenzo Fernandez

Andreas Mitschke hem, its not declared. :) But i thought that with coffee script you didnt have to. (I'm clearly not a pro)

Benjamin Den Boer
Lorenzo Fernandez

awesome!!!

Lorenzo Fernandez

works.

Read the entire post on Facebook