[英]as3 change all button colors
我正在嘗試使用以下代碼替換所有名為“ myButtons”的按鈕的顏色:
colorTransform.color = 0xaf4b44;
myButtons.transform.colorTransform = colorTransform;
但只有最近創建的按鈕會更改顏色,而不是全部。 它們都稱為myButtons。 還有另一種方法嗎?
如果所有按鈕都具有相同的父項,則可以使用以下代碼。 我建議您為每個按鈕使用不同的名稱。
var colorTransform:ColorTransform=new ColorTransform;
colorTransform.color = 0xaf4b44;
var mc:MovieClip=new MovieClip;
mc=root["myButtons"].parent;
for(var i:int=0; i<mc.numChildren; i++){
if(mc.getChildAt(i).name=="myButtons"){
mc.getChildAt(i).transform.colorTransform = colorTransform;
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.