[]扩展脚本问题,麻烦帮看下
module game {
export class testbox extends Laya.Box {
constructor(){
super();
console.log(this.getChildByName('btnName'))
}
}
export class testImg extends Laya.Image {
constructor(){
super();
console.log(this.getChildByName('name'))
console.log(this)
}
}
}
我这两个分别绑定在了image和box上面,但是就是不能通过getChildByName获取到子元素,这是为什么,this.numChild也为0,
没有找到相关结果
已邀请:
1 个回复
Aar0n
赞同来自:
module game {
用这个代码export class testbox extends Laya.Box {
constructor(){
super();
this.frameOnce(2,this,this.onFrame);
}
private onFrame():void{
console.log("111"+this.getChildByName('btnName'))
}
}
export class testImg extends Laya.Image {
constructor(){
super();
this.frameOnce(2,this,this.onFrame);
}
private onFrame():void{
console.log("122"+super.getChildByName('name'))
console.log("133"+this)
}
}
}