setFinishCallback problem

What am I doing wrong? Error: ‘Wrong type of AudioClip’

cc.Class({
extends: cc.Component,

properties: {
    audio1: {
        default: null,
        type: cc.AudioClip
    },
    audio2: {
        default: null,
        type: cc.AudioClip
    }
},

onLoad() {
    var id = cc.audioEngine.play(this.audio1, false, 1);
    cc.audioEngine.setFinishCallback(id, function () {
        cc.audioEngine.play(this.audio2, false, 1);
    });
},

});

I can ask engineering to have a look.

Thanks, but no longer needed. I was stupidly wrong. Copied the function from the documentation and didn’t notice that there was no arrow function there.

That’s correct:
onLoad() {
var id = cc.audioEngine.play(this.audio1, false, 1);
cc.audioEngine.setFinishCallback(id, () => {
cc.audioEngine.play(this.audio2, false, 1);
});
}

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.