All good I figured it out.
// Check if a clone has already been created
if (!project.hasCloned) {
var thing = clone_R.clone();
thing.x = 720;
thing.y = 405;
thing.rotation = 0;
// Ensure the shape inside the clone is properly accessed and modified
var shape = thing.timeline.layers[0].frames[0]._children[0];
if (shape) {
shape.fillColor = [1, 0, 0]; // Set fill color to red
shape.scaleX = 1; // Ensure scale is preserved
shape.scaleY = 1;
}
// Debug: Log scripts before clearing
console.log("Before clearing, scripts:", JSON.stringify(thing.scripts, null, 2));
// Remove the 'default' script from the main clip
thing.removeScript("default");
// Add back the 'default' script with empty source
thing.addScript("default", "");
// Check for nested clips and handle their 'default' scripts
function clearAndAddNestedScripts(obj) {
if (obj._children) {
obj._children.forEach(child => {
if (child.scripts && child.scripts.length > 0) {
console.log("Found scripts in child:", JSON.stringify(child.scripts, null, 2));
child.removeScript("default");
child.addScript("default", "");
}
clearAndAddNestedScripts(child); // Recurse into nested children
});
}
}
clearAndAddNestedScripts(thing);
// Create a 20x20 black rectangle
var rectJson = {
type: "path",
shape: "rectangle",
x: -10, // Center the 20x20 rectangle
y: -10,
width: 20,
height: 20,
fillColor: [0, 0, 0] // Black fill
};
// Create a new Wick.Path object
var newRect = new Wick.Path(rectJson);
// Add the new rectangle to the same frame as the shape
thing.timeline.layers[0].frames[0].addPath(newRect);
// Set the clip as a clickable link
thing.link = "https://www.google.com/url?sa=i&url=https%3A%2F%2Fwww.imdb.com%2Fname%2Fnm0124165%2F&psig=AOvVaw2ZtfjQvqjkUDiW3weabgzk&ust=1752112364396000&source=images&cd=vfe&opi=89978449&ved=0CBAQjRxqFwoTCLDQw7TVro4DFQAAAAAdAAAAABAE";
// Debug: Log the rectangle and link properties
console.log("New rectangle added:", JSON.stringify(rectJson, null, 2));
console.log("Clip link set:", thing.link);
// Ensure changes are saved during serialization
thing.json = thing.serialize();
// Debug: Confirm scripts after adding back
console.log("After clearing and adding, scripts:", JSON.stringify(thing.scripts, null, 2));
// Add the clone to the parent frame's children
this.parentFrame.addChild(thing);
// Update the project's serialized data
this.parentFrame._cachedSerializeData.children.push(thing.uuid);
// Mark that a clone has been created
project.hasCloned = true;
}