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

What is Framer? Join the Community
Return to index
Marc Krenn
Posted Jan 04 - Read on Facebook

Would love to get some help from the pros :)

I've come up with this recursive function that prints the hierarchy of a layer. To my surprise this terrible hackjob ended up working but there must be a better way to do this.

Would you please point me in the right direction?

Thanks!

http://share.framerjs.com/evj3h58040c9/

6 Comments

Joshua Tucker

Hey Marc! How's this (deleted previous post because had a mistake :P)?

Marc Krenn

Thanks Joshua :)

Should have been a bit more precise. This is just an abstraction of another problem where I can't use native Framer methods. So I'd like you to replace '.subLayers[0]" with ".foobar()" or something else in your mind.:D

Joshua Tucker

Ahah! Makes sense. Back to the coding board :P.

Marc Krenn

Jordan, halp plz :)

JL Flores Mena

Hey Marc, I'm not sure what you're trying to achieve because you mentioned you can't use Framer methods, however in your example you're using layers and their 'superlayer' attribute.

The solution Joshua provided is correct, but if you want to do it without Framer functions here are two alternatives. Both options rely on the 'layers' array and assume that your first element in the array is your outmostLayer (according to your example).

Goes without saying: these functions shouldn't have the same name, it was just to illustrate both have the same output.

Hope this helps!

Joshua Tucker

Nice JL Flores Mena! You're awesome! Sorry Marc Krenn got distracted with work stuff :).

Read the entire post on Facebook