Clip copy vs clip clone

Hi,

If I copy a clip using copy / paste and I change the original, the copy doesn’t change with it. If I use Adobe Flash and a create a copy of a movieclip and change it, all instances change with it.
How can that behaviour be replicated in Wick-editor?

  • I read that I can use .clone, but that is at run-rime. I want to create clones at design-time.
  • I tried adding my clip to the asset library and populate the canvas from there, but when I change one of these, the others stay the same.

That is one of the main difference between Flash and WickEditor. It is a trade off, there is not a built-in option to make it work as Flash.

Correct me if I’m wrong, but Wick’s .clone does what flash does if you copy-paste a movieclip at design-time, right? Could this function be added to the design-time editor?

Suppose I have 20 identical clips (at designtime) and I want to make a small change to the code. Do I need to change all 20 of them?

In my opinion a clip is like a class, and the objects you put on the stage are instances of that class. In the Wick-editor every clip you put on the stage seems to be a new class even if it is a copy of another clip. That feels wrong. Or am I missing something?

No, in wick editor, a clip is an instance of a WickClip. You can add properties at run time, but it will only affect that instance. Everything clone from an instance is still a clone of an instance (kind of redundant, but you get the point…). A clone is a new instance with the source clip properties at clone time. After that whatever you do with both (cloned and source clips), they will be totally independent from each other.

Copy and Paste of a clip instance at design time, is a clone instance, not a reference of the same instance.

Hi Jovanny,

Thanks for explaining this.

Just to be sure: If I have a clip with some code in it, and I make 20 copies of it, the code will be replicated 20 times. Changes to the code of one instance will not affect the other. And there is no way for me to change that (not even using .clone at runtime) and refreshing the clip in the asset library will also not affect the clips that are already on stage, right?

Correct!

Correct! As any other js OOP class.

There is no way, that is the point of an instance of a class. I don’t see any scenario where you want 2 instances of a clip to behave the same… they will have the same position, scale, rotation, etc… so you will not be able to see one of them.

WickClip is a class made in js. Whatever you can accomplish in js, is what you should be able to accomplish here.

Thank you for clearifying!

1 Like

If you’d like to edit the code for multiple clips from one place, I’d recommend using a function.

Example

Here’s an example in case anyone wants one

Paste this code into multiple clips:

project.FunctionName(this);

(Change “FunctionName” with what you’d like to call the function)

In the default script of the frame, define what the function does:

project.FunctionName = function(clip){
// Use "clip" to refer to the object
clip.x+=10; // This is an example
}

All objects that have this function will run the code “clip.x+=10;” in this example, and you can change that line or add more to it in order to have it better fit your project.

1 Like

Thanks for this tip Hamzah.
Some background information:
I want to make an HMI.
Pumps etc will be in the asset library and have their own code to change their appearance depending on tag values. Tag values are taken from an MQTT server. Users should be able to just drag, drop and name the assets. I’m planning on assigning tags to the assets over MQTT too so changes to it will appear immediately on all active screens.

Bert

1 Like

What a nice, innovative idea!
Love to would seen the implementation, if you care to share it!

I’ve not finished the project yet though I made a POC.
I find it quite hard to get to a good solution.
Once finished I’m convinced that it will be a great solution!
I’ve done it before, but in Flash. The Javascript / HTML stuff is quite a bit different.
I would be willing to share for the purpose of finishing the project.
(Are you Dutch by any chance?)