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

What is Framer? Join the Community
Return to index
Dan Clarke
Posted Aug 03 - Read on Facebook

Me again! Anyone have a good resource for learning more about modules?
I have a module in a project but I would like to position it to whatever location I desire. I'd also like to duplicate it within the project?

14 Comments

Chris Camargo

The answers to your questions depend on how the module was written. Code would help in this case.

Dan Clarke

Hi Chris Camargo, Here's a real basic example. I want to create a layer in my module. include it in my project, change it's x,y co-ordinates and make a copy

Dan Clarke

Module contains:

exports.button1 = new Layer
width: 150
height: 150
x: 100
y:100

Dan Clarke

framer contains:

module = require "myModule"

module.button1
x:400
y:400

Dan Clarke

but when i reference with module.button1 framer throws an error

Dan Clarke

I can upload the framer file but that's really it to get me started

Antonio Krämer Fernandez

here is an example how you could use a module for a button: http://share.framerjs.com/rclf3edh6esq/

The trick is that you use a function to draw the button and define the Events so you can use it again. If you are not familiar with functions than this should be your next step to learn.

Dan Clarke

That's great Antonio Krämer Fernandez! I see now how it needs to be a function, makes sense. I'll get to it

Dan Clarke

working great, got it figured out, thanks!

Dan Clarke

So say I want to access part of a function, how would I do that, based on your example? I tried it in this project but to no avail...

http://share.framerjs.com/o7gv4jrtah7r/

Antonio Krämer Fernandez

one way is by adding an Array that stores all buttons so its possible to access them later.
http://share.framerjs.com/yg1o32x7mzp5/

Everytime the function is called it pushes the new button into the array allButtons.

Dan Clarke

ah, very cool. Although what I intended to do was to change the text on the buttons themselves, via the changeHTML layer...

Dan Clarke

so that when you click the blue layer. the button that says "start" changes to saying "hello". or the background colour would change, for instance

Antonio Krämer Fernandez

ah then you just need to switch it around:
changeHMTL.on Events.Click, ->
module.allButtons[0].html = "hello"
module.allButtons[1].html = "hello"

Read the entire post on Facebook