lundi 23 janvier 2017

Animate / EaselJS - removeEventListener not working

I have an issue w/ Adobe Animate CC, and the Javascript framework it uses, EaselJS/CreateJS. I can add event listeners w/o issue, but I cannot remove them. I have tried various things from the debugger, including stepping into their JS removeEventListener handler - Although the two variables look identical, they are never == (or ===) so the even listener isn't removed.

Here is the code I use, and it's purpose it to fade-in an element when hovering over it:

this.fadeIn = function(target_mc)
    {
        target_mc.alpha = 0;
        target_mc.visible = true;

        target_mc.removeEventListener("tick",fadeIn_onEnterFrame);
        target_mc.addEventListener("tick",fadeIn_onEnterFrame.bind(this));

        function fadeIn_onEnterFrame(evt)
        {
            evt.currentTarget.alpha = evt.currentTarget.alpha + .2;
            if (evt.currentTarget.alpha >= 1)
            {
                evt.currentTarget.removeEventListener("tick",fadeIn_onEnterFrame);
            } // end if
        }
    } // End of the function

So you know, it is added to the Canvas in frame_0, and is called from a "mouseover" listener added to each clothing type (it's for a drag-and-drop dress-up game, FWIW)

function clothing_onRollOver()
{
    this.hint_mc.desc_mc.desc1_txt.text = this.articleName;
    this.fadeIn(this.hint_mc);
    this.clothingOver = true;
};
clothing.addEventListener("mouseover",clothing_onRollOver.bind(this));

Aucun commentaire:

Enregistrer un commentaire