0

我正在尝试为 Flex 中的按钮设置皮肤,但是在为按钮设置皮肤后,我在其中链接的图标消失了。我知道我可以将图标添加到皮肤中,但这意味着我必须创建许多不同的皮肤。

有什么简单的方法可以解决这个问题吗?

.mxml 文件:

<?xml version="1.0" encoding="utf-8"?>
<s:View xmlns:fx="http://ns.adobe.com/mxml/2009"
        xmlns:s="library://ns.adobe.com/flex/spark"
        xmlns:ns1="*"
        xmlns:packageservice="services.packageservice.*"
        title="My Dish"
        fontSize.Beef="10" textAlign.Beef="center">
    <fx:Script>
        <![CDATA[
            import com.adobe.serializers.utility.TypeUtility;

            import mx.events.FlexEvent;




            protected function list_creationCompleteHandler(event:FlexEvent):void
            {
                my_get_beef_dishResult.token = packageService.my_get_beef_dish();
            }


            protected function list2_creationCompleteHandler(event:FlexEvent):void
            {
                my_get_pork_dishResult.token = packageService.my_get_pork_dish();
            }


            protected function list3_creationCompleteHandler(event:FlexEvent):void
            {
                my_get_chicken_dishResult.token = packageService.my_get_chicken_dish();
            }


            protected function list4_creationCompleteHandler(event:FlexEvent):void
            {
                my_get_fish_dishResult.token = packageService.my_get_fish_dish();
            }


            protected function list5_creationCompleteHandler(event:FlexEvent):void
            {
                my_get_vegetables_dishResult.token = packageService.my_get_vegetables_dish();
            }

        ]]>
    </fx:Script>
    <s:states>
        <s:State name="Beef"/>
        <s:State name="Pork"/>
        <s:State name="Chicken"/>
        <s:State name="Fish"/>
        <s:State name="Vegetables"/>
        <s:State name="Other"/>
    </s:states>
    <s:navigationContent>
        <s:Button label="Back" click="navigator.popView();"/>
    </s:navigationContent>
    <fx:Declarations>
        <s:CallResponder id="my_get_beef_dishResult"/>
        <packageservice:PackageService id="packageService"/>
        <s:CallResponder id="my_get_pork_dishResult"/>
        <s:CallResponder id="my_get_chicken_dishResult"/>
        <s:CallResponder id="my_get_fish_dishResult"/>
        <s:CallResponder id="my_get_vegetables_dishResult"/>

        <!-- Place non-visual elements (e.g., services, value objects) here -->
    </fx:Declarations>
    <s:VGroup x="0" y="0" width="245" height="364" contentBackgroundColor="#E6E6E6">                                                      
        <s:List id="MyDishOther" includeIn="Other" width="245" height="364" contentBackgroundColor="#E6E6E6"></s:List>
        <s:List id="list" includeIn="Beef" width="245" height="365"
                creationComplete="list_creationCompleteHandler(event)" labelField="name">
            <s:AsyncListView list="{my_get_beef_dishResult.lastResult}"/>
        </s:List>
        <s:List id="list2" includeIn="Pork" width="245" height="365"
                creationComplete="list2_creationCompleteHandler(event)" labelField="name">
            <s:AsyncListView list="{my_get_pork_dishResult.lastResult}"/>
        </s:List>
        <s:List id="list3" includeIn="Chicken" width="245" height="365"
                creationComplete="list3_creationCompleteHandler(event)" labelField="name">
            <s:AsyncListView list="{my_get_chicken_dishResult.lastResult}"/>
        </s:List>
        <s:List id="list4" includeIn="Fish" width="245" height="365"
                creationComplete="list4_creationCompleteHandler(event)" labelField="name">
            <s:AsyncListView list="{my_get_fish_dishResult.lastResult}"/>
        </s:List>
        <s:List id="list5" includeIn="Vegetables" width="245" height="365"
                creationComplete="list5_creationCompleteHandler(event)" labelField="name">
            <s:AsyncListView list="{my_get_vegetables_dishResult.lastResult}"/>
        </s:List>
    </s:VGroup>

...

        <s:Button includeIn="Beef" width="70"  icon="assets/beef.png" skinClass="components.Stab"/>
        <s:Button includeIn="Beef" width="60" click="currentState='Chicken'" icon="assets/chicken.png"/>
        <s:Button includeIn="Beef" width="60" click="currentState='Fish'" icon="assets/fish(1).png"/>
        <s:Button includeIn="Beef" width="60" click="currentState='Pork'" icon="assets/porktest(1).png"/>
        <s:Button includeIn="Beef" width="60" icon="assets/t_vegetables.png" click="currentState='Vegetables'"/>

.....

    </s:VGroup>
</s:View>

皮肤等级:

<?xml version="1.0" encoding="utf-8"?>

<s:Skin xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" alpha.disabled=".5">

    <!-- states -->

    <s:states>

        <s:State name="up" />

        <s:State name="over" />

        <s:State name="down" />

        <s:State name="disabled" />

    </s:states>

    <!-- layer 2: fill -->
    <s:Rect left="1" right="1" top="1" bottom="1" radiusX="2" radiusY="2">
        <s:fill>
            <s:LinearGradient rotation="90">
                <s:GradientEntry color="0xFFFFFF" 
                                 color.over="0xBBBDBD" 
                                 color.down="0xAAAAAA" 
                                 alpha="0.85" />
                <s:GradientEntry color="0xD8D8D8" 
                                 color.over="0x9FA0A1" 
                                 color.down="0x929496" 
                                 alpha="0.85" />
            </s:LinearGradient>
        </s:fill>
    </s:Rect>

    <!-- layer 2: border -->
    <s:Rect left="0" right="0" top="0" bottom="0" width="60" height="45" radiusX="2" radiusY="2">
            <s:stroke>

            <s:LinearGradientStroke rotation="90" weight="1">
                <s:GradientEntry color="0x000000" 
                                 alpha="0.5625"
                                 alpha.down="0.6375" />
                <s:GradientEntry color="0x000000" 
                                 alpha="0.75" 
                                 alpha.down="0.85" />
            </s:LinearGradientStroke>
            </s:stroke>
    </s:Rect>




</s:Skin>
4

1 回答 1

0

我猜到问题是你的皮肤不是从 SparkButtonSkin 继承的。图标功能在其中实现,默认按钮皮肤继承 SparkButtonSkin。

于 2012-11-06T14:15:24.083 回答