javascriptcreatejsadobe-animate

Changing colour of the shape clicked in HTML5 canvas Adobe Animate


this.movieClip_1.addEventListener("click", fl_MouseClickHandler.bind(this));

function fl_MouseClickHandler()
{
movieClip_1.fillColor = color.green;
}

I am a beginner here and I am unable to find any online resources which can allow me to learn the script which is required for making HTML5 content via Adobe Animate.

In my above code, I try to change the colour of the movieclip on a MouseClick event. However, I do not think I have the right syntax.

Thank you.


Solution

  • var mc = this.movieClip_1;
    mc.addEventListener("click", fl_MouseClickHandler);
    mc.cache(0, 0, 200, 200); //important [0,0,width movieclip, height movieclip]
    function fl_MouseClickHandler()
    {
        mc.filters = [new createjs.ColorFilter(0,0,0,1,55, 184, 51, 0)]; //set green over offset RGB
        mc.updateCache(); //important
    }
    

    see more: https://createjs.com/docs/easeljs/classes/ColorFilter.html