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

What is Framer? Join the Community
Return to index
John Smith
Posted May 07 - Read on Facebook

I am currently running a for loop to create series of layers that I place within a page component

for i in [2..0]
slide = new Layer
width: Screen.width
height: 624
image: "images/slide"+i+".png"
x: 750 * i
name: "slide" + i
parent: carousel.content

For some reason I can't seem to reference the clips ie ( slide0.onTap -> et. etc.). There a reason for why I am unable to reference the layer by the name?

5 Comments

Ian McClure

slide0 isn't the variable name. Name in a object is a property of the object. It's variable name is slide, which gets destroyed when the loop ends, and it has a property called name that holds a string.

You can either add them to an array and grab them from that or use carousel.content.childWithName({your layer's .name property})

John Smith

Thanks for the explanation Ian.

Ian McClure

Not a problem.

Steve Ruiz

I agree with Ian that an array will be your best bet. I'd also recommend using carousel.addPage() rather than setting the new page using the layer's parent property.

John Smith

Thanks Steve.

Read the entire post on Facebook