Skip to main content
praktisdesign
Participant
April 8, 2020
Question

Change color of a Movie Clip in an Animate Canvas document

  • April 8, 2020
  • 3 replies
  • 1538 views

Hello, I have situation - presently rebuilding the project from AS3 to HTML5 Canvas. I need some advise how can I change color of Movie Clip with code ?

Code in AS3:
komodamenu1_mc.spalv81_btn.addEventListener(MouseEvent.CLICK,komoda81);
function komoda81(event:MouseEvent):void {
var myColorTransform:ColorTransform = new ColorTransform()
myColorTransform.color = (0xdab396);//RAL 1001
komoda1_mc.transform.colorTransform=myColorTransform
}

The Live flash version: https://bilijardai.lt/sites/default/files/SWF%20failai/Pronto%20Ultra/Bill%20ULTRA%20konstr%202017_1%20OutAS.html

    This topic has been closed for replies.

    3 replies

    Participating Frequently
    April 9, 2020

    Filters just kill the performance in my CC Animate (HTML Canvas) project. I learend to stay away from them. If  I need a cool (static) filter effect, I just import an image with the content and the filter. (HTML Canvas) works well with bitmaps,but not programmatically adding filters

    Participating Frequently
    April 8, 2020

    if it's a shape you can easily change the shape color inside a movie clip using the code below

    mc.shape.graphics._fill.style "#3399CC"  // with no stroke
    mc.shape_1.graphics._fill.style "#3399CC" //with stroke
     
    praktisdesign
    Participant
    April 21, 2020

    Hello, thank you for reply. I made the sample with shape and put your suggested code - it doesn't work.
    Can you send me any working sample on An with code?

    Legend
    April 8, 2020

    https://www.createjs.com/docs/easeljs/classes/ColorFilter.html

     

    Note that the HTML5 canvas element doesn't natively support filter effects, so they must be implemented pixel-by-pixel in JavaScript. This can be rather slow depending on the size of the image.