Draw Canvas problem with javascript (plugin)

Get help using Construct 2

Post » Sun Jan 13, 2013 4:55 pm

I really surprised...

My plugin is worked very well in build r95..
Problem comes after I attempt to update to r114.
Javascript library don't recognize the context of element...???

My code as bellow:

     instanceProto.paint = function (myparam)
     {
      //alert("here: "+ this.runtime.id);      
      //alert(this.x);
      var _x = this.x;
      var _y = this.y;
      var _w = this.width;
      var _h = this.height;
        //this.runtime.trigger(pluginProto.cnds.ImageLoaded,instance);
        var image = new Image();
        image.src = myparam;               
        image.onload= function(){
            var c=document.getElementById("c2canvas");
            var con=c.getContext('2d');
            if(null == con){
               alert("con is null");
               return;
            }
            con.drawImage(image, _x - _w/2, _y- _h/2, _w,_h);
        }
           //this.draw(con);
           //this.runtime.redraw=true;
        this.image = image;
       
     };


In test bed, alert message always topup "con is null"...this problem never appeared in old build
Some one please help me...how to solve this problem

Thank in advance
B
11
S
2
Posts: 73
Reputation: 1,438

Return to How do I....?

Who is online

Users browsing this forum: armaldio, plinkie and 18 guests