For the moment, I'm creating behaviors dealing with the HTML image inside the Sprite object.
I usually get it back with that line of code :
this.inst.type.animations[0].frames[this.inst.cur_frame].texture_img.src;
I do what I need to do with that (usually drawing it on another private canvas to modify it).
When I want to inject it back (as a base64 string), it updates in Chrome, but not in Firefox.
To clarify my problem, here's a typical piece of code :
var tmpImage;
var base64str;
this.tmpImg.onload = function(){
ctx.drawImage(tmpImg, 0, 0,tmpImg.width,tmpImg.height);
//do my thing
base64str = cvs.toDataURL("image/png");
inst.cur_animation.frames[inst.cur_frame].texture_img.onload = (function (self) {
return function(info) {
inst.set_bbox_changed();
cr.runtime.redraw = true;
};
})(this);
?
?img.src = base64str;
?cr.runtime.redraw = true;
}
this.tmpImg.src = this.inst.type.animations[0].frames[this.inst.cur_frame].texture_img.src;
It works perfectly in Chrome.
However, although the new "img.src" of the Sprite contain, indeed, the base64 string, FF doesn't update.
When I do that kind of things outside C2's SDK, it works perfectly on FF and Chrome (see here, for example : http://jsfiddle.net/2Unnf/).
So, here's my question : what's the right way to inject an image inside the Sprite object, when dealing with onload() methods ?