參考:
按鈕有3個狀態,up down disabled。這里區別於source,source.down,source.disabled,而是每個狀態單獨一個image。
且每個單獨的<image>標簽有一個特別的屬性includeIn,這里表示該圖片的狀態。
<e:RadioButton id="testBtn" label="" x="398" y="62" anchorOffsetX="0" width="142" anchorOffsetY="0" height="62"> <e:skinName> <e:Skin states="up,down,disabled"> <e:Image width="100%" height="100%" source="book_scale1_0_png" includeIn="up" id="radio_pic_up"/> <e:Image width="100%" height="100%" source="book_scale1_1_png" includeIn="down" id="radio_pic_down"/> <e:Image width="100%" height="100%" source="book_scale1_2_png" includeIn="disabled" id="radio_pic_disabled"/> <e:Label id="labelDisplay" horizontalCenter="0" verticalCenter="0"/> </e:Skin> </e:skinName> </e:RadioButton>
代碼中根據圖片id獲取按鈕的圖片["radio_pic_up"],再賦值新的texture就可以動態改變按鈕的圖片了。
this.testBtn["radio_pic_up"].texture = RES.getRes("0_png");
this.testBtn["radio_pic_down"].texture = RES.getRes("1_png");
this.testBtn["radio_pic_disabled"].texture = RES.getRes("2_png");
