Uncaught TypeError: Cannot set property 'src' of null on cc.Sprite.js : 1137

Hello all,

I have created a class called Bug :

var Bug = cc.Sprite.extend({

ctor:function (file_name) {

this.initWithFile(file_name);
}
});

I want to create an object for that class as
this.sprite = new Bug(redBug);

But it gives an error “Uncaught TypeError: Cannot set property ‘src’ of null on
cc.Sprite.js : 1137”

The problem is that this.*blendFunc is null and we are trying to set values.
this.*blendFunc.src = cc.BLEND_SRC;
this._blendFunc.dst = cc.BLEND_DST;

But , this.sprite = new Bug(redBug); works fine .

Thanks in Advance.

Hi,srikanth chitturi.
When you rewrite ctor ,you must call the super, like the following:

var Bug = cc.Sprite.extend({
ctor:function  (file_name) {
      this._super();
      this.initWithFile(file_name);
    }
});

this._super() call the ctor of cc.Sprite that init some default value.