Sign in to follow this  
trial

How to make a global fadeOut function?

Recommended Posts

in Animate CC, how do I make a global fadeOut function? In my canvas I have a Square and a Circle movieclip acting as buttons.

I want to be able to click on each and have them fadeOut. Instead of writing the fadeOut code individually, is it possible to just usea global function?

I don't really know what I'm doing. Found Adobe's page about Convert your ActionScript code to HTML5. I tried my hand at it, but I'm stuck at this:

 //Square btn
this.square_mc.addEventListener("click", square_mcClick.bind(this));

function square_mcClick() {
    fadeOut();
}

// Circle btn
this.circle_mc.addEventListener("click", circle_mcClick.bind(this));

function circle_mcClick() {
    fadeOut();
}

// Global fadeOut function
function fadeOut() {
this.addEventListener('tick', fl_FadeSymbolOut.bind(this));

this.alpha = 1;

function fl_FadeSymbolOut() {
    this.alpha -= 0.01;
    if (this.alpha <= 1) {
        this.removeEventListener('tick', fl_FadeSymbolOut.bind(this));
    }
}

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.