推荐阅读:1.createChildren是皮肤初始化创建和添加组件调用
2.childrenCreated是在组件初始化完成后回调
3.addtostage是被addchild到舞台的时候执行
例1:
class TestSkin extends eui.Component {
constructor() {
super();
this.addEventListener(eui.UIEvent.COMPLETE,this.onComplete,this);
this.skinName = "resource/testSkin.exml";
}
protected createChildren() {
super.createChildren();
console.log("11111111")
}
private onComplete():void{
console.log("222222222");
}
}
先输出111111,后输出222222,可见执行createChildren时是取不到皮肤上的组件的。
例2:主题加载皮肤
{
"skins": {
"eui.Button": "skins/ButtonSkin.exml",
"eui.CheckBox": "skins/CheckBoxSkin.exml",
"eui.HScrollBar": "skins/HScrollBarSkin.exml",
"eui.HSlider": "skins/HSliderSkin.exml",
"eui.Panel": "skins/PanelSkin.exml",
"eui.ProgressBar": "skins/ProgressBarSkin.exml",
"eui.RadioButton": "skins/RadioButtonSkin.exml",
"eui.Scroller": "skins/ScrollerSkin.exml",
"eui.ToggleSwitch": "skins/ToggleSwitchSkin.exml",
"eui.VScrollBar": "skins/VScrollBarSkin.exml",
"eui.VSlider": "skins/VSliderSkin.exml"
},
"exmls": [ ],
"autoGenerateExmlsList": true
}
使用例1的代码先输出22222,再输出11111