[英]flex, change the button image when mouse over/out
使用以下代碼,當鼠標懸停按鈕時,我已經實現了圖像更改。 但圖片名稱是硬編碼的,在樣式中指定。 如何使其參數化? 我想重用帶有圖像名稱作為輸入參數的這個小實用程序。 所有使用的圖像(在我的情況下為14張圖像)都將包含在flex項目中。 我正在使用flex 3
<mx:Style>
.myCustomButton {
upSkin: Embed(source="jjyxfx.png");
overSkin:Embed(source="cwgl.png");
downSkin: Embed(source="cwgl.png");
}
</mx:Style>
<mx:Button y="0" width="105" height="107" fillAlphas="[1.0, 1.0, 1.0, 1.0]" x="0" fillColors="[#3AA2D9, #3AA2D9]" styleName="myCustomButton" useHandCursor="true" buttonMode="true"/>
我不相信您無法參數化CSS樣式; 因此您必須通過ActionScript設置樣式:
public function setStylesOnButton(upSkinValue:String,overSkinValue:String,downSkinStyle:String):void{
myButton.setStyle('upSkin',upSkinValue);
myButton.setStyle('overSkin',overSkinValue);
myButton.setStyle('downSkin',downSkinStyle);
}
確保按鈕具有ID,以便可以在ActionScript中訪問它:
<mx:Button id="myButton" y="0" width="105" height="107" fillAlphas="[1.0, 1.0, 1.0, 1.0]" x="0" fillColors="[#3AA2D9, #3AA2D9]" styleName="myCustomButton" useHandCursor="true" buttonMode="true"/>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.