Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

151
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!