Flex 4 中的皮肤按钮标签

发布于 2024-10-20 18:23:20 字数 1774 浏览 4 评论 0原文

我在 Flex 4 中为按钮使用皮肤。皮肤按钮显示正确。

现在我希望按钮的标签做出如下响应:

  • 当“RollOver”或“MouseOver”位于按钮上时,字体粗细应为粗体。

我尝试在下面的 mxml 中通过将 rollOver 属性包含到此按钮上的标签中来执行此操作,但它似乎不起作用。

我是否在正确的位置(即 Skin mxml 文件中)执行此操作?或者我应该为应用程序本身的每个按钮执行此操作?

皮肤代码:

<?xml version="1.0" encoding="utf-8"?>
<s:SparkSkin xmlns:fx="http://ns.adobe.com/mxml/2009" 
             xmlns:s="library://ns.adobe.com/flex/spark" 
             xmlns:mx="library://ns.adobe.com/flex/mx">

    <fx:Metadata>
        <![CDATA[ 
        [HostComponent("spark.components.Button")]
        ]]>
    </fx:Metadata>

    <fx:Script>
        <![CDATA[
            protected function labelDisplay_rollOverHandler(event:MouseEvent):void
            {
                FontWeight.BOLD;
                FontStyle.ITALIC;
            }
        ]]>
    </fx:Script>

    <s:states>
        <s:State name="up" />
        <s:State name="over" />
        <s:State name="down" />
        <s:State name="disabled" />
    </s:states>

    <s:BitmapImage includeIn="up" source="{getStyle('upSkin')}" width="100%" height="100%"/>

    <s:BitmapImage includeIn="over" source="{getStyle('overSkin')}" width="100%" height="100%"/>

    <s:BitmapImage includeIn="down" source="{getStyle('downSkin')}" width="100%" height="100%"/>

    <s:BitmapImage includeIn="disabled" source="{getStyle('disabledSkin')}" width="100%" height="100%"/>

    <s:Label id="labelDisplay" textAlign="right" maxDisplayedLines="1" horizontalCenter="1"
             verticalAlign="middle" verticalCenter="1" left="10" right="10" rollOver="labelDisplay_rollOverHandler(event)" />

</s:SparkSkin>

I am using a Skin for my buttons in Flex 4. The skinned buttons are displayed correctly.

Now I want the label of the buttons to respond as such:

  • Font Weight should be Bold when "RollOver" or "MouseOver" over the buttons.

I tried doing it in the mxml below by including the rollOver property to the Label on this button, but it doesnt seem to work.

Am I doing it at the right place, that is in the Skin mxml file? Or should I do it for each button in the Application itself?

Skin Code:

<?xml version="1.0" encoding="utf-8"?>
<s:SparkSkin xmlns:fx="http://ns.adobe.com/mxml/2009" 
             xmlns:s="library://ns.adobe.com/flex/spark" 
             xmlns:mx="library://ns.adobe.com/flex/mx">

    <fx:Metadata>
        <![CDATA[ 
        [HostComponent("spark.components.Button")]
        ]]>
    </fx:Metadata>

    <fx:Script>
        <![CDATA[
            protected function labelDisplay_rollOverHandler(event:MouseEvent):void
            {
                FontWeight.BOLD;
                FontStyle.ITALIC;
            }
        ]]>
    </fx:Script>

    <s:states>
        <s:State name="up" />
        <s:State name="over" />
        <s:State name="down" />
        <s:State name="disabled" />
    </s:states>

    <s:BitmapImage includeIn="up" source="{getStyle('upSkin')}" width="100%" height="100%"/>

    <s:BitmapImage includeIn="over" source="{getStyle('overSkin')}" width="100%" height="100%"/>

    <s:BitmapImage includeIn="down" source="{getStyle('downSkin')}" width="100%" height="100%"/>

    <s:BitmapImage includeIn="disabled" source="{getStyle('disabledSkin')}" width="100%" height="100%"/>

    <s:Label id="labelDisplay" textAlign="right" maxDisplayedLines="1" horizontalCenter="1"
             verticalAlign="middle" verticalCenter="1" left="10" right="10" rollOver="labelDisplay_rollOverHandler(event)" />

</s:SparkSkin>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

那请放手 2024-10-27 18:23:21

您可以通过更改“over”状态的 fontWeight 样式轻松完成此操作。您可以在 MXML 中执行此操作,方法是指定样式,后跟您希望应用该样式的状态,如下所示:

<s:Label id="labelDisplay" fontWeight.over="bold" textAlign="right" maxDisplayedLines="1" horizontalCenter="1"
         verticalAlign="middle" verticalCenter="1" left="10" right="10" />

希望有帮助。

You can do this easily by changing the fontWeight style for the "over" state. You can do this in MXML by specifying the style followed by the state you want that style to be applied to, like so:

<s:Label id="labelDisplay" fontWeight.over="bold" textAlign="right" maxDisplayedLines="1" horizontalCenter="1"
         verticalAlign="middle" verticalCenter="1" left="10" right="10" />

Hope that helps.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文