Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

149
Visualizações
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:

function onMouseUp(evt){
    var item = evt.currentTarget;
    item.drag = false;
    var pt = item.localToLocal(item.dot.x, item.dot.y, item.LFLensHolder.hitBox);
    if(item.LFLensHolder.hitBox.hitTest(pt.x, pt.y) ){
        item.x = item.LFLensHolder.x;
        item.y = item.LFLensHolder.y;
        item.lensParentLeft.addChild(item);
        }
}

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

function onMouseMove(evt){
    var item = evt.currentTarget;
    if (item.drag){
        var pt = item.parent.globalToLocal(evt.stageX, evt.stageY);
        item.x = pt.x - item.offset.x;
        item.y = pt.y - item.offset.y;
    }
}
about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

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

if (someParent.contains(evt.currentTarget)) {
  // Do something
}

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

about 4 years ago · Juan Pablo Isaza Relatório

0

This worked for me:

if (item.parent == this.lensParentLeft) {
      //do stuff
    }

In this case I just wanted to change the parent of the symbol with an instance name of item from lensParentLeft to the stage.

So, I added this.addChild(item); inside the braces.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda