Actionscript 3 在Flex 4中为按钮蒙皮的图像
我正在尝试用图像给按钮蒙皮 以下代码适用于Flex3,但我需要Flex4代码中的等效代码。 不使用皮肤类Actionscript 3 在Flex 4中为按钮蒙皮的图像,actionscript-3,apache-flex,flex4,Actionscript 3,Apache Flex,Flex4,我正在尝试用图像给按钮蒙皮 以下代码适用于Flex3,但我需要Flex4代码中的等效代码。 不使用皮肤类 .muteVolumeButton { upSkin: Embed(source='images/sound-mute.gif'); overSkin:Embed(source='images/sound-hover.gif'); downSkin: Embed(source='images/sound-on.gif'); disabledSkin: Em
.muteVolumeButton
{
upSkin: Embed(source='images/sound-mute.gif');
overSkin:Embed(source='images/sound-hover.gif');
downSkin: Embed(source='images/sound-on.gif');
disabledSkin: Embed(source='images/sound-mute.gif');
}
请发布Flex4代码。我应该说Spark框架中的蒙皮与Halo方式有点不同 最好的描述是。这是解决你问题的最好最简单的方法。 以下是代码: components.ImageButton.as 脚本: MXML部分:
在所有其他情况下,您始终可以通过CSS对状态进行蒙皮
@namespace s”library://ns.adobe.com/flex/spark";代码>
s|按钮:down
在皮肤中打开脚本标记并执行以下操作:
[Embed(source="assets/images/button-up.png", scaleGridLeft = "4", scaleGridRight = "5", scaleGridTop = "2", scaleGridBottom = "3")]
[Bindable]
public var upImg:Class;
[Embed(source="assets/images/button-over.png", scaleGridLeft = "4", scaleGridRight = "5", scaleGridTop = "4", scaleGridBottom = "5")]
[Bindable]
public var overImg:Class;
[Embed(source="assets/images/button-disabled-skin.png", scaleGridLeft = "4", scaleGridRight = "5", scaleGridTop = "2", scaleGridBottom = "3")]
[Bindable]
public var disabledImg:Class;
[Embed(source="assets/images/button-over.png", scaleGridLeft = "4", scaleGridRight = "5", scaleGridTop = "4", scaleGridBottom = "5")]
[Bindable]
public var downImg:Class;
删除所有默认填充,改为使用:
<s:BitmapImage source="{upImg}"
source.over="{overImg}"
source.down="{downImg}"
source.disabled="{disabledImg}"
width="100%"/>
瞧,谢谢你提供的信息。但是为什么adobe在flex4中删除了最简单的通过css对按钮进行Flex3图像蒙皮的功能呢?我面临的困难是用不同的图像对多个按钮进行蒙皮。在spark框架中,更灵活的方法是用图像扩展按钮,然后通过css进行设置。比如+1给尤金一个好答案。是的,您必须通过皮肤来实现这一点,但好消息是,您可以创建一次通用皮肤,然后通过在CSS中设置图像将其用于任何按钮,就像您在Flex 3中所做的那样。
<components:ImageButton buttonMode="true"
imageSkin="{btnGo}" imageSkinDisabled="{btnGoDisabled}"
imageSkinDown="{btnGoOver}" imageSkinOver="{btnGoOver}"
skinClass="assets.skins.ImageButtonSkin"/>
[Embed(source="assets/images/button-up.png", scaleGridLeft = "4", scaleGridRight = "5", scaleGridTop = "2", scaleGridBottom = "3")]
[Bindable]
public var upImg:Class;
[Embed(source="assets/images/button-over.png", scaleGridLeft = "4", scaleGridRight = "5", scaleGridTop = "4", scaleGridBottom = "5")]
[Bindable]
public var overImg:Class;
[Embed(source="assets/images/button-disabled-skin.png", scaleGridLeft = "4", scaleGridRight = "5", scaleGridTop = "2", scaleGridBottom = "3")]
[Bindable]
public var disabledImg:Class;
[Embed(source="assets/images/button-over.png", scaleGridLeft = "4", scaleGridRight = "5", scaleGridTop = "4", scaleGridBottom = "5")]
[Bindable]
public var downImg:Class;
<s:BitmapImage source="{upImg}"
source.over="{overImg}"
source.down="{downImg}"
source.disabled="{disabledImg}"
width="100%"/>