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

What is Framer? Join the Community
Return to index
Tom Jenkins
Posted Mar 23 - Read on Facebook

Hello,
Can you use .subLayers[<index>] and .subLayersByName("name") interchangeably?
I get the same Layer object printed by using either, but cannot do anything else with subLayersByName. Bug?
Thanks
Tom

Sample code:

wrapperLayer = new Layer width:256, height:256
iconLayer = new Layer width:256, height:256, image:"images/framer-icon.png", name: "icon", superLayer: wrapperLayer

# prints - <Layer id:2 name:icon (0,0) 256x256>
print wrapperLayer.subLayersByName("icon")
# prints - <Layer id:2 name:icon (0,0) 256x256>
print wrapperLayer.subLayers[0]

# Doesn't work
wrapperLayer.subLayersByName("icon").visible = false
# Works
wrapperLayer.subLayers[0].visible = false

2 Comments

Jordan Robert Dobson

ByName is still an array. That's thrown me off before. Remember two layers could have the same name. So just do wrapperLayer.subLayersByName("icon")[0] and you'll be good.

Tom Jenkins

Ah ha! :) Thanks Jordan

Read the entire post on Facebook