Reputation: 25
sorry for stupid question, i need to animate all sublayers in some particular layer. How to iterate through all the sublayers?
Upvotes: 2
Views: 3908
Reputation: 61
I came across this question looking for a similar solution. I wanted to change all subLayers in a given layer, even deep nested layers. In the Docs I found descendants. Adding here in case someone is looking for a solution to iterate all nested subLayers.
for descendant in layers
descendant.ignoreEvents
Upvotes: 0
Reputation: 353
You can iterate sublayers of a layer via for-in loop
for child in layer.subLayers
child.animate
properties:
x: Utils.randomNumber(100)
y: Utils.randomNumber(100)
if you need an index of each sublayer, you can change loop like this
for child, i in layer.subLayers
Upvotes: 3