[]ProgressBar 代码问题
依照官网教程https://layaair.ldc.layabox.com/demo/?2d&UI&ProgressBar
使用会出现<<<TypeError: Cannot read property 'value' of undefined>>>
我的代码为按钮点击后
出现popup并且模拟进度条加载
按钮代码:
this.testLoadingBar_anim.on(Event.CLICK,this,()=>{
var loading : Onloading = new Onloading();
loading.popup(true);
Laya.timer.loop(100, this, loading.changeValue);
});
进度条代码:
import Handler = Laya.Handler;
export class Onloading extends ui.LoadingUI{
constructor(){
super();
this.loadingBar.changeHandler = new Handler(this, this.onChange);
}
public changeValue():void{
console.log("change");
if (this.loadingBar.value >= 1){
this.loadingBar.value = 0;
}
this.loadingBar.value += 0.05;
}
onChange(value: number): void {
console.log("进度:" + Math.floor(value * 100) + "%");
}
}
使用会出现<<<TypeError: Cannot read property 'value' of undefined>>>
我的代码为按钮点击后
出现popup并且模拟进度条加载
按钮代码:
this.testLoadingBar_anim.on(Event.CLICK,this,()=>{
var loading : Onloading = new Onloading();
loading.popup(true);
Laya.timer.loop(100, this, loading.changeValue);
});
进度条代码:
import Handler = Laya.Handler;
export class Onloading extends ui.LoadingUI{
constructor(){
super();
this.loadingBar.changeHandler = new Handler(this, this.onChange);
}
public changeValue():void{
console.log("change");
if (this.loadingBar.value >= 1){
this.loadingBar.value = 0;
}
this.loadingBar.value += 0.05;
}
onChange(value: number): void {
console.log("进度:" + Math.floor(value * 100) + "%");
}
}
没有找到相关结果
已邀请:
要回复问题请先登录
3 个回复
Aar0n
赞同来自:
Aar0n
赞同来自:
Jarvan
赞同来自:
你这个绑定的this是父级this 改成loading 你试下