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

What is Framer? Join the Community
Return to index
Rich Price
Posted Aug 21 - Read on Facebook

NBQ #2 :) Ok, so I was playing with the import function from Sketch. Worked well, and I could distort the layer(button) in coffee script just fine. Then I wanted to move it somewhere else on the stage, but I'm struggling to understand these objects(layers). I found a sample in the Docs for the Align function. I can't figure out why doing these align functions on myButton isn't appropriate. It works on a new layer, but not on the layer I brought in from Sketch. Any ideas?

12 Comments

Jordan Robert Dobson

Is it a child of root? Or another layer or what?

Rich Price

I don't know. I'm brand new to this. :)

Jordan Robert Dobson

print myButton.parent

Rich Price

I assume it is, since the first thing I have is an imported group and I created a reference to it.

Rich Price

Looks like null

Jordan Robert Dobson

Huh.

Jordan Robert Dobson

myButton.point = Align.center()

Rich Price

I think I may not understand layers as objects and which operations I can do on them, when. Ok, I'll try that.

Jordan Robert Dobson

Yeah. That's cool.

Jordan Robert Dobson

myButton.x = 200

Jordan Robert Dobson

All the properties listed in the docs under layer can be used with dot notation... Most, if not all, can be done upon creation.

Rich Zarick

Hey Rich, one part of importing from sketch that you should look into is the Utils.globalLayers function. You may have noticed that your imported sketch layers can only be targeted if you reference them through a variable (like you did in your project with myButton), or by continuously writing 'projectLayers' as a prefix for every sketch layer.

If you use the one-liner Utils.globalLayers(projectLayers) after your import function, you can go about targeting them by their original layer name from sketch!

Read the entire post on Facebook