Skip to main content
تقنية المعلومات
Known Participant
April 22, 2019
Question

Error in color code .. HTML5 Canvas

  • April 22, 2019
  • 1 reply
  • 607 views

this.stop();
function color1() {
var myColor: ColorTransform = new ColorTransform;
this.brush.mainbrush.transform.colorTransform = myColor;
this.myColor.color = "#000000";
}
this.brush.addEventListener("click", brushmc.bind(this));
function brushmc() {
this.brush.startDrag(true, new Rectangle(W: 550, H: 400));
}
this.Green.addEventListener("click", Greencolor.bind(this));
function Greencolor() {

this.brush.main.transform.colorTransform = myColor;
this.myColor.color = "#006600";
}
this.Yellow.addEventListener("click", Yellowcolor.bind(this));
function Yellowcolor() {

this.brush.main.transform.colorTransform = myColor;
this.myColor.color = "#FFFF00";
}
this.box.addEventListener("click", boxcolor.bind(this));
function boxcolor() {
if ((this.brush.main.transform.colorTransform = "#FFFF00")) {
  this.good.visible = true;
  this.good.play();
  this.box.transform.colorTransform = "#FFFF00";
} else {
  this.good.visible = false;
  this.wrong.alpha = 1;
  this.box.transform.colorTransform = "#FFFFFF";
}

https://drive.google.com/file/d/1jH-YszEE2yHEG7pAvJY6ZkZH4iImW9sA/view?usp=sharing

This topic has been closed for replies.

1 reply

JoãoCésar17023019
Community Expert
Community Expert
April 22, 2019

Hi.

You are mixing AS3 and JavaScript.

Use color filters to change colors or access the shapes inside of your Movie Clips instances if you're not exporting your document as texture.

Color Filter reference:

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

Hypothetical way of changing a fill color of a shape inside of a Movie Clip if the document or the object is not being exported as a texture:

var root = this;

root.start = function(e)

{

    root.yourMovieClipName.children[0].graphics._fill.style = "#FF0000";

};

stage.on("drawstart", root.start, null, true);

Regards,

JC