Hello all. Posting a general question, even though I feel silly thinking I'm making an obvious mistake somewhere... But whatever. Here goes.
I'm trying to make a pagination widget in Framer Studio, and I decided to use a simple for loop structure to do so. It looks like this:
totalPages = [1..5] # This will be an array of PSD layers later
markerGap = 40
for pageNumber in totalPages
pageMarker = new Layer
name: "marker" + pageNumber
y: action.height - 25
if pageNumber is 1
pageMarker.backgroundColor = "rgb(255 ,255, 255)"
pageMarker.backgroundColor = "rgb(0, 0, 0)"
pageMarker.style = "border": "1px solid rgb(255, 255, 255)"
pageMarker.borderRadius = pageMarker.width/2
markerGap += 20
This does what I expect, creates five dots with the first one filled to indicate Page 1 is active for the default state. I can change totalPages to get more markers, etc., and it all draws fine. I'll be using some layers in a PSD file in totalPages, but for now, it's just numbers to create objects.
So, my question is this: How do I call the different pageMarker objects so I can set different states or properties? I've tried all of the various object name notations in JS that I can remember, but all I keep getting back is undefined. What I was trying to do was something like this:
pageMarker["marker3"].backgroundColor = "rgb (124, 124, 124)"
Thinking that the "name" property might be used to grab the object, but no dice (because I've not created an array here I assume). And there doesn't appear to be a Framer Utils function that will allow me to grab the object once it's been created.
I also tried using something like:
paginationWidget = for pageNumber in totalPages
But the values returned when I print paginationWidget is a set of numbers: [60,80,100,120,140] in this case.
It seems that the only way to get the object is to give it a unique variable name when you make the layer in the first place. And if that's true, how should I go about doing that using a for loop statement like above? (IOW, how would I create a variable in pageMarker that becomes unique each time the loop is iterated.
Like I said, I feel like I'm making a rookie mistake somewhere, and it's been a few years since I've touched JS, so I'm blanking here.