Laya.timer.callLater导致null值问题


__proto.posChanged=function(ani){
        if (this._aniFlag==0)
            this._aniFlag=ani ? 1 :-1;
        else if (this._aniFlag==1 && !ani)
        this._aniFlag=-1;
        this._needRefresh=true;
        Laya.timer.callLater(this,this.refresh);
    }
    __proto.refresh=function(){
        this._needRefresh=false;
        Laya.timer.clear(this,this.refresh);
        if (this._pageMode || this._snapToItem){
            ScrollPane.sEndPos.setTo(-this._xPos,-this._yPos);
            this.alignPosition(ScrollPane.sEndPos,false);
            this._xPos=-ScrollPane.sEndPos.x;
            this._yPos=-ScrollPane.sEndPos.y;
        }
        this.refresh2();
        Events.dispatch("fui_scroll",this._owner.displayObject);
        if (this._needRefresh){
            this._needRefresh=false;
            Laya.timer.clear(this,this.refresh);
            this.refresh2();
        }
        this.syncScrollBar();
        this._aniFlag=0;
    }

ScrollPane中的refresh执行的时候this._owner.displayObject可能已经为空,原因未找到,目前只能添加空值判断

if(this._owner.displayObject == null){
return;
}
 
已邀请:

谷主

赞同来自:

可以加上判断。空就表示对象已经被dispose了。

要回复问题请先登录注册