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
Switch Layer Problem
Moderators: Víctor Paredes, Belgarath, slowtiger
Re: Switch Layer Problem
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~
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
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
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
- synthsin75
- Posts: 10271
- Joined: Mon Jan 14, 2008 11:20 pm
- Location: Oklahoma
- Contact:
Re: Switch Layer Problem
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).
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).
- Wes
Donations: https://www.paypal.com/paypalme/synthsin75 (Thx, everyone.)
https://www.youtube.com/user/synthsin75
Scripting reference: https://mohoscripting.com/
Donations: https://www.paypal.com/paypalme/synthsin75 (Thx, everyone.)
https://www.youtube.com/user/synthsin75
Scripting reference: https://mohoscripting.com/
Re: Switch Layer Problem
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.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).
- synthsin75
- Posts: 10271
- Joined: Mon Jan 14, 2008 11:20 pm
- Location: Oklahoma
- Contact:
Re: Switch Layer Problem
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.
- Wes
Donations: https://www.paypal.com/paypalme/synthsin75 (Thx, everyone.)
https://www.youtube.com/user/synthsin75
Scripting reference: https://mohoscripting.com/
Donations: https://www.paypal.com/paypalme/synthsin75 (Thx, everyone.)
https://www.youtube.com/user/synthsin75
Scripting reference: https://mohoscripting.com/