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

148
Visualizações
how to access the currentTarget movie clip from a button click

I need help with JavaScript in Adobe AnimateCC:

I have two different movie clips and a button. I would like to be able to click on a movie clip (making it the currentTarget) and then click on a button which calls the currentTarget (the just-clicked-on movie clip) and makes it do something -- move 500 px along x for example. Here's my code so far. Any help will be greatly appreciated.

this.grayPentagon_1_mc.addEventListener("click", clickSomePentagon.bind(this));
this.grayPentagon_2_mc.addEventListener("click", clickSomePentagon.bind(this));

function clickSomePentagon(e)
{
    alert(e.currentTarget);
    var myPentagon = e.currentTarget;
}

this.red_btn_1.addEventListener("click", makeSomePentagonMove.bind(this));

function makeSomePentagonMove()
{
    alert("move my pentagon");
    myPentagon.x = 500; 
}

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

My bad, I apologize. I should have declared the variable var myPentagon outside the function clickSomePentagon, then referenced the declared variable in the function, like this, which works.

var myPentagon;

this.grayPentagon_1_mc.addEventListener("click", clickSomePentagon);
this.grayPentagon_2_mc.addEventListener("click", clickSomePentagon);

function clickSomePentagon(e)
{
    //alert(e.currentTarget);
    myPentagon = e.currentTarget;
}

this.red_btn_1.addEventListener("click", makeSomePentagonMove.bind(this));

function makeSomePentagonMove()
{
    //alert("move my pentagon");
    myPentagon.x = 500; 
}

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