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

What is Framer? Join the Community
Return to index
Alexander Bennett
Posted Nov 27 - Read on Facebook

With the awesome help of Weston Thayer I was able to figure out how to automatically generate uniquely named layers. Unfortunately I'm having trouble using those unique names to have them do stuff after they have been generated. Like events based on clicking them, or animations.

Any help would be greatly appreciated :-)

Sample Project:

4 Comments

Alexander Bennett

The code in the sample project:

Weston Thayer

So inside your bg.on Events.Click handler, you have a variable called testLayer that gets created on every click. You can use it just like you use the bg layer, but the caveat is that it's only available inside the click handler (btw, the click handler is just a function).

So if you wanted to only animate even ones, you could say:
if dotNumber % 2 == 0
testLayer.animate
...etc...

This would be just before you say dotNumber = dotNumber + 1. The "%" is the modulus operator. It just means 'take dotNumber and divide it by two, but then tell me what the remainder is'. If there isn't a remainder when dividing by 2, the number must be even.

Marc Krenn

Alexander, hopefully this answers most of your questions:
http://share.framerjs.com/ylme99z1offj/

:)

Alexander Bennett

Weston and Marc, thank you so much! I really appreciate all the help and am learning so much. Building the array of layers is so cool and makes so much sense now. :-D

Read the entire post on Facebook