cc.ActionInterval.extend is not a Function?

With Javascript/Web project this code will work:

/** Rotates a cc.Node object to a certain angle by modifying it's
* rotation attribute. 
* The direction will be decided by the shortest angle.
* @class
* @extends cc.ActionInterval
*/
rs.SizeTo = cc.ActionInterval.extend({
    _dstValue:0,
    _startValue:0,
    _diffValue:0,
    /**
     * @param {Number} duration
     * @param {Number} deltaAngleX
     * @param {Number} deltaAngleY
     * @return {Boolean}
     */
    initWithDuration:function (duration, value) {
        if (cc.ActionInterval.prototype.initWithDuration.call(this, duration)) {
            this._dstValue = value || 0;
            return true;
        }
        return false;
    },

    /**
     * @param {cc.Node} target
     */
    startWithTarget:function (target) {
        cc.ActionInterval.prototype.startWithTarget.call(this, target);
        this._startValue = target.getContentSize();
        this._diffValue = this._dstValue - this._startValue.width;
    },

    /**
     * RotateTo reverse not implemented
     */
    reverse:function () {
        cc.Assert(0, "RotateTo reverse not implemented");
    },

    /**
     * @param {Number} time time in seconds
     */
    update:function (time) {
        if (this._target){
            this._target.setContentSize(new cc.Size(this._startValue.width + (this._diffValue * time), this._startValue.height));
        }
    }
});

How can one extends the action interval class for Cocos2d-x Android/JS project?
Because in android Debug error gives:

DEBUG/cocos2d-x debug info(24129): JS: assets/progressBar.js:127:TypeError: cc.ActionInterval.extend is not a function
1 Like

Hi, I figured out how to remove the Error:

added the Line below, to jsb_cocos2d.js:

cc.ActionInterval.extend = cc.Class.extend;

.

New problem now that when the Update Method is called, i get just Console output and no changes on my JS.:

Output:

[Action update]. override me
[Action update]. override me
[Action update]. override me
[Action update]. override me
[Action update]. override me

I added a cc.log() to my code above to check for the Update function:

    /**
     * @param {Number} time time in seconds
     */
    update:function (time) {
        cc.log("SizeTo: "+(this._startValue.width + (this._diffValue * time)));

        if (this._target){
            this._target.setContentSize(new cc.Size(this._startValue.width + (this._diffValue * time), this._startValue.height));
        }
    }

But this code is never getting called…?

I have the same problem, no answers?

Hello terry,

I have begun to solve the problem above by implementing the “rs.SizeTo” Class as Native code, and then generating a JSB from it and loading that JSB in my AppDelegate.

That should get you in the right direction.