Page 1 of 1

Switch Layer Problem

Posted: Thu Aug 28, 2014 5:00 am
by dkwroot
MY GOAL:
I would like the user to be able to draw on a switch layer and have whatever they draw get placed on frame 0 of the currently active sub-layer. This will allow users to easily do FBF animations in a form similar to flash and other FBF programs.

THE PROBLEM:
When the switch layer is selected, I first find the name of the active layer. Then I do a 'for loop' and look for a sub-layer that matches the name. This gives me the MohoLayer of my sub-layer. I executed the function MohoLayer:LayerType() and got 1, which means it's a vector layer. The problem is that when I try to access the mesh for this vector layer, the program always tells me that the Mesh() function is nil.

Now correct me if I'm wrong, but "Vector Layers" are the same as "MeshLayer", right? If you check the API for MeshLayer, you'll see the function "Mesh()", but the programs seems to be ignoring this ... any ideas?

LINK TO MESH LAYER API: http://aslua.com/index.php?show=class&name=MeshLayer

Re: Switch Layer Problem

Posted: Thu Aug 28, 2014 5:29 am
by dkwroot
YES! Figured it out.

It turns out that the MohoLayer you get from the ":Layer(id)" function is a generic MohoLayer. You then have to cast it to the vector type using LayerAsVector(layer).

Sweeeeeeeeeeeeet~

Re: Switch Layer Problem

Posted: Thu Aug 28, 2014 6:35 am
by dkwroot
NEW PROBLEM:
I can now draw on a child layer from the parent switch layer. The problem that I'm having is that I can't create a shape for a child layer from the parent. It seems that the createshape function is localized to moho, which is strictly the currently selected layer.

I did see that LM_MeshPreview has a createshape function, but I don't know anything about it. I'm not even sure how to define a variable as an object of the MeshPreview class. Any ideas?

LINK: http://aslua.com/index.php?show=class&n ... eshPreview

Re: Switch Layer Problem

Posted: Sat Aug 30, 2014 3:14 am
by synthsin75
MeshPreview is used by things like the Star menu script. It gives a preview of the shape from the dialog.

I would suggest selecting the sublayer briefly to create the shape (you should be able to do this fast enough that the user hardly notices).

Re: Switch Layer Problem

Posted: Mon Sep 01, 2014 3:08 am
by dkwroot
synthsin75 wrote:MeshPreview is used by things like the Star menu script. It gives a preview of the shape from the dialog.

I would suggest selecting the sublayer briefly to create the shape (you should be able to do this fast enough that the user hardly notices).
This was my original plan, but I was worried that it would cause the screen to flicker a little or the switch layer would rapidly expand and collapse every time the user draws. Thankfully this doesn't happen at all! The developers chose not to auto-update the UI when you switch layers in code, which is wonderful.

Re: Switch Layer Problem

Posted: Mon Sep 01, 2014 6:05 am
by synthsin75
Yeah, showing the layer selected by a script is optional. I have even gotten away with showing a different layer's timeline, although I don't remember how well it works now days.