Skip to content
Advertisement

How can I check if a symbol/MC is a child of another symbol/MC?

I’m using Adobe Animate HTML5 Canvas. EaselJS would also apply.

How can I check if a symbol/MC is a child of another symbol/MC?

So a symbol/MC is added as a child of lensParentLeft in the following. I then want to check if it is a child of that parent in a later function:

JavaScript

The later function being the following, probably in the if(item.drag) condition statement:

JavaScript

Advertisement

Answer

You can use the contains method. It does a recursive parent check up to the stage to find an ancestor.

https://createjs.com/docs/easeljs/classes/Container.html#method_contains

JavaScript

Note that contains will also return true if you check a symbol against itself.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement