Is this how to create a new clip?

I keep getting a console log error that says cannot create _parent for this.

project.timeline.layers[0].frames[0].addClip(“myClip”);

Can someone please show me my error?

Luke

Are you trying to add an existing WickClip? or are you trying to add it from the library?
Meamwhile, few things to try…

  • since myClip should be a symbol, try not to use " "
  • instead of layers, frames, etc… try with _children[0]._children[0]

Hi Jovanny,
I am trying to add a fresh new clip without cloning or pulling an asset onto the canvas. I want to fill it with assets that I create programmatically.
I’ll try what you suggest.
Thanks.

Try replacing “addClip” with “addChild,” and inside the parenthesis you want to have an object (a clip).

Take a look at this code below, it uses a clone of an object from another frame, and with the “addChild” function it adds that clip to another frame.

^ I found the addChild code by playing around with the editor, Jovanny used it to make these two functions above, and I added in the comments to make them easier to understand. You might only need to read the first function to understand how to add a clip to a frame from code.

In order to create the clip that you want to add, rather than making a clone in another frame and adding it in, you’ll need to define all properties of the clip.
To get an idea of how a clip is defined inside a wick project, I suggest trying this:

  1. Make a new empty wick project
  2. Create a clip that’s similar to what you want
  3. Save the wick file
  4. Change the wick file’s format to zip and look inside
  5. Look for the clip inside the json file
1 Like