Jump to content

How to make a global fadeOut function?


trial
 Share

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));
    }
}

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...