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

200
Views
¿Cómo hacer que las versiones de código .on y .addEventListener funcionen en Animate CC?

Sólo estoy tratando de averiguar cómo funcionan los códigos. Sé que .on es como un atajo y funciona así:

 this.circle_mc.on("pressmove", function (evt) { var point = stage.globalToLocal(evt.stageX, evt.stageY) evt.currentTarget.x = point.x; evt.currentTarget.y = point.y; });

así que pensé que la forma .addEventListener también funcionaría, pero no es así.

 this.circle_mc.addEventListener("pressmove", evt.bind(this)); function evt() { var point = stage.globalToLocal(evt.stageX, evt.stageY) this.circle_mc.x = point.x; this.circle_mc.y = point.y; }

pero no lo hace ¿Cómo hace que funcione la versión .addEventListener?

Actualización: no estoy seguro de cuáles son objetos JS/elementos HTML/eventos DOM, pero de alguna manera conseguí que funcionara usando este código:

 this.circle_mc.addEventListener("pressmove", evt.bind(this)); function evt() { var point = stage.globalToLocal(stage.mouseX, stage.mouseY) this.circle_mc.x = point.x; this.circle_mc.y = point.y; }

Pensé que cuando uso .addEventListener, llama a la función fuera de él. Tanto evt.stageX como evt.stageY siempre serían 0. Cuando lo cambié a stage.mouseX y stage.mouseY, funcionó igual que la versión de acceso directo .on.

Aunque lo hice funcionar, espero que alguien pueda explicarlo más claramente, porque todavía es confuso para mí.

2da actualización: alguien en el foro de Adobe Animate mencionó que lo hiciera de esta manera, entonces no necesitaría cambiar el escenarioX/escenarioY a mouseX/mouseY.

 function evt(e) { var point = stage.globalToLocal(e.stageX, e.stageY) this.circle_mc.x = point.x; this.circle_mc.y = point.y; }
about 4 years ago · Juan Pablo Isaza
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!