Reputation: 186
I have a .fla file where I have symbols to change skin, hair and shirt colors in a boy draw. When I export it with CreateJS I got this:
// 1Hair
this.shape_226 = new cjs.Shape();
this.shape_226.graphics.f("#FCDEC4").s().p("AA").cp();
this.shape_226.setTransform(0.1,-95.3);`
There you can see a color (#FCDEC4) that stands for hair color, I tried replacing the color for one variable (boyHair), like this
// 1Hair
this.shape_226 = new cjs.Shape();
this.shape_226.graphics.f(boyHair).s().p("AA").cp();
this.shape_226.setTransform(0.1,-95.3);`
This is the init function of the file generated
//Modified from exported file of Flash Toolkit for CreateJS
var canvas, stage, exportRoot;
function init() {
canvas=document.getElementById("canvas");
exportRoot=new lib.characters();
stage=new createjs.Stage(canvas);
stage.addChild(exportRoot);
stage.update();
createjs.Ticker.setFPS(24);
createjs.Ticker.addListener(stage);
}
I set the value on my main JavaScript file like this:
var boyHair="#000000";
And works the first time (I guess at initialization stage) but if I modify the value later on the code, it has no effect on canvas draw, I tried with stage.update()
but it does nothing as well.
Do you know if there's a way to change those colors dinamically?
Thanks in advance
Upvotes: 0
Views: 1341
Reputation: 730
Try to do something like this
var canvas, stage, exportRoot;
function init()
{
canvas=document.getElementById("canvas");
exportRoot=new lib.characters();
stage=new createjs.Stage(canvas);
stage.addChild(exportRoot);
createjs.Ticker.setFPS(24);
createjs.Ticker.addEventListener ("tick", tick);
}
tick =function()
{
var boyHair="#000000";
stage.update();
}
Upvotes: 0
Reputation: 11294
There is not currently a way - you will have to reconstruct your Shapes when the color changes.
Upvotes: 0