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

What is Framer? Join the Community
Return to index
Noah Tsutsui
Posted Sep 04 - Read on Facebook

Can i haz the help? :)

6 Comments

Ed Chao

Create an array that stores a bunch of objects. Each object can have a property called img and the value is the image url. Loop through this array and create a new layer each time setting its image to the image in the currently indexed object. That's it :)

Noah Tsutsui

Thanks Ed, that worked! So my next question is, how do I later reference those layer objects?

Ed Chao

when you create each layer you can store it in an array. later you can grab each layer by referencing that array by index.

Noah Tsutsui

I guess you mean using the push method? Still stuck though... why won't it change the opacity...
tabNames = ["nearby", "adopted", "my_cats", "settings", "bruce"]
tabs = []

for tab in tabNames
new Layer
x:0, y:0, width:640, height:1136, image:"images/#{tab}.jpg", opacity: 0
tabs.push tab

tabs[1].opacity = 1

Chad Lonberger

Could do something like..

layerArr = {}
for tab, index in tabNames
layerArr[index] = new Layer...

Ed Chao

Actually, I prefer to use .map. So instead of "for tab, index in tabNames" I usually do something like [0..tabNames.length-1].map (i) -> ... tabs[i] = new Layer ...

Read the entire post on Facebook