[]扩展脚本问题,麻烦帮看下

 
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,
已邀请:

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)
}
}
}
用这个代码

该问题目前已经被锁定, 无法添加新回复

商务合作
商务合作