nav*_*een 3 apache-flex actionscript-3 flex4
我正在尝试用图像修饰一个按钮.
以下代码适用于flex 3,但我需要flex 4代码中的等效代码.不使用皮肤类.
.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');
}
Run Code Online (Sandbox Code Playgroud)
请发布flex 4代码.
我应该说Spark框架中的外观与Halo方式略有不同.
最好的描述在这里.这是解决问题的最佳和最简单的方法.这是代码:
components.ImageButton.as
package components
{
import spark.components.Button;
[Style(name="imageSkin",type="*")]
[Style(name="imageSkinDisabled",type="*")]
[Style(name="imageSkinDown",type="*")]
[Style(name="imageSkinOver",type="*")]
public class ImageButton extends Button
{
public function ImageButton()
{
super();
}
}
}
Run Code Online (Sandbox Code Playgroud)
脚本:
[Embed('assets/images/btnGoUp.png')]
[Bindable]
public var btnGo:Class;
[Embed('assets/images/btnGoOver.png')]
[Bindable]
public var btnGoOver:Class;
[Embed('assets/images/btnGoDisabled.png')]
[Bindable]
public var btnGoDisabled:Class;
Run Code Online (Sandbox Code Playgroud)
MXML部分:
<components:ImageButton buttonMode="true"
imageSkin="{btnGo}" imageSkinDisabled="{btnGoDisabled}"
imageSkinDown="{btnGoOver}" imageSkinOver="{btnGoOver}"
skinClass="assets.skins.ImageButtonSkin"/>
Run Code Online (Sandbox Code Playgroud)
在所有其他情况下,您始终可以通过CSS 为状态设置外观.
@namespace s "library://ns.adobe.com/flex/spark";s|Button:down以下是一些有用的链接:
http://blog.flexexamples.com/2009/03/03/styling-an-emphasized-fxbutton-control-in-flex-gumbo/
http://opensource.adobe.com/wiki/display/flexsdk/CSS+Namespaces+Support
http://cookbooks.adobe.com/post_How_to_use_the_new_CSS_syntax_in_Flex_4-15726.html