addEventListener and the scope of this

后端 未结 3 656
时光说笑
时光说笑 2021-01-02 04:53

I have a third party flash object which i can manipulate through a javascript API they provided. I am tryind to listen to an event on this object and then fire event inside

3条回答
  •  半阙折子戏
    2021-01-02 05:37

    What about creating an external variable before referencing to 'this' object. For example:

    var _this = this;
    this.chart.addEventListener('create', function() { _this.fireEvent('created'); }, false)
    

提交回复
热议问题