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

124
Views
Set button state - Create.js/Easel.js

In Adobe Animate HTML5 Canvas (Create.js/Easel.js), I am trying to set the state of a button, but not working with various code:

this.retinoscopeButton.addEventListener("click", retinoscope.bind(this));

/*function retinoscope(evt) {
    var retinoscopeButtonState = evt.currentTarget.state = !evt.currentTarget.state;
    if (retinoscopeButtonState) {
        alert(retinoscopeButtonState);
        this.retinoscopeButton.upState = this.retinoscopeButton.downState;
    } else {
        this.retinoscopeButton.downState = this.retinoscopeButton.upState;
    }
}*/

var retinoscopeButtonState = 'up';

function retinoscope(evt){ 
    if (retinoscopeButtonState == 'up'){
    this.retinoscopeButton.upState = this.retinoscopeButton.downState;
        retinoscopeButtonState = 'down';
    } else if (retinoscopeButtonState == 'down'){
    this.retinoscopeButton.downState = this.retinoscopeButton.upState;
        retinoscopeButtonState = 'up';
    }
}
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

This works for me...

Note that this is using a MovieClip with three keyframes for the different 'states' in the button MC retinoscopeButton

var toggle;

if (!root.retinoscopeButton.hasEventListener("click")) {
    toggle = false;
    root.retinoscopeButton.addEventListener("click", retinoscopeButtonClickHandler.bind(this));
}


root.retinoscopeButton.addEventListener("mouseover", retinoscopeButtonRollOverHandler.bind(this));
root.retinoscopeButton.addEventListener("mouseout", retinoscopeButtonRollOutHandler.bind(this));


function retinoscopeButtonClickHandler() {
    if (toggle == false) {
        root.retinoscopeButton.gotoAndStop(2);
        toggle = true;
    } else if (toggle == true) {
        root.retinoscopeButton.gotoAndStop(0);
        toggle = false
    }
}

function retinoscopeButtonRollOverHandler() {
    if (toggle == false) {
        root.retinoscopeButton.gotoAndStop(1);
    }
}

function retinoscopeButtonRollOutHandler() {
    if (toggle == false) {
        root.retinoscopeButton.gotoAndStop(0);
    }
}
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!