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

What is Framer? Join the Community
Return to index
Luis Escobar
Posted Jul 30 - Read on Facebook

Hey all! Does anyone know if you can use Utils.randomChoice without duplication?


Jonas Treub

Here is how you can do it:
items = [0...10]
shuffled = _.shuffle(items)
getShuffledItem = => return shuffled.pop()
print getShuffledItem()

Luis Escobar

Thanks, Jonas Treub... but how would I use this in a loop? Sorry, still somewhat of a noob.

This is what I'm currently working with:

count = 0
imgSources = ("images/img_#{i}.jpg" for i in [1..12])

for column in [0...4]
for row in [0...3]
pic = new Layer
name: imgSources[count]
x: row * (Screen.width/3 + 5)
y: column * (Screen.height/4 + 5)
width: Screen.width/3
height: Screen.height/4
image: imgSources[count]
backgroundColor: "orange"
pic.num = count++

Jonas Treub

Here is how I would do it:

Read the entire post on Facebook