1

我有一个带有自定义皮肤的窗口应用程序,并且皮肤包含标题栏,它也使用自定义皮肤。现在的问题是,如果窗口设置为全屏,我需要动态隐藏最小化和最大化按钮。请帮忙...

我的标题栏皮肤代码

<s:SparkSkin xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" 
                     xmlns:fb="http://ns.adobe.com/flashbuilder/2009" xmlns:mx="library://ns.adobe.com/flex/mx" 
                     minHeight="24">

            <fx:Metadata>
                [HostComponent("spark.components.windowClasses.TitleBar")]
            </fx:Metadata> 

            <s:states>
                <s:State name="normal" />
                <s:State name="disabled" />
                <s:State name="normalAndMaximized" stateGroups="maximizedGroup" />
                <s:State name="disabledAndMaximized" stateGroups="maximizedGroup" />
            </s:states>

            <!-- fill -->   
            <!--- Defines the background color of the skin. -->
            <s:Rect id="background" 
                    left="0" right="0" top="0" bottom="0">
                <s:fill>
                    <s:LinearGradient>
                        <s:GradientEntry color="#2ecbd8"/>
                        <s:GradientEntry color="white" ratio="0.45"/>
                        <s:GradientEntry color="white" ratio="0.55"/>
                        <s:GradientEntry color="#2ecbd8"/>
                    </s:LinearGradient>
                </s:fill>
            </s:Rect>

            <s:Group 
                id="contentGroup"
                minHeight="24"
                width="100%" 
                height="100%"
                left="10" 
                right="10" >

                <s:layout>
                    <s:HorizontalLayout verticalAlign="middle" horizontalAlign="center" gap="5" />
                </s:layout>

                <s:BitmapImage id="titleIconImage" minWidth="0" fillMode="clip"/>

                <s:Label id="titleText" text="{hostComponent.title}" minWidth="0" fontSize="9" color="#585858" maxDisplayedLines="1" width="100%" />


                <s:Button id="minimizeButton"
                          skinClass="spark.skins.spark.windowChrome.MinimizeButtonSkin"
                          top="2" bottom="2" verticalCenter="0"
                          />

                <s:Button id="maximizeButton"
                          skinClass="spark.skins.spark.windowChrome.MaximizeButtonSkin"
                          top="2" bottom="2" verticalCenter="0"
                          />

                <s:Button id="closeButton" 
                          skinClass="spark.skins.spark.windowChrome.CloseButtonSkin"
                          verticalCenter="0"  />
                <fx:Script>
                    <![CDATA[
                        import spark.skins.spark.windowChrome.MaximizeButtonSkin;
                    ]]>
                </fx:Script>

            </s:Group>
        </s:SparkSkin>

我的窗口应用程序皮肤代码

<?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" 
                xmlns:mx="library://ns.adobe.com/flex/mx" 
                xmlns:ui="com.youspin.components.ui.*"
                depth="-10">
            <!-- host component -->
            <fx:Metadata>
                [HostComponent("spark.components.WindowedApplication")]
            </fx:Metadata>

            <!-- states -->
            <s:states>
                <s:State name="disabledAndInactive" />
                <s:State name="normalAndInactive" />
                <s:State name="disabled" />
                <s:State name="normal" />
            </s:states> 

            <s:TitleBar left="0" right="0" top="1"
                        title="YouSpin"
                        height="{0.067*height}" 
                        skinClass="skins.titleSkin"/>   

            <s:Group  id="contentGroup" left="0" top="0" right="0" bottom="0" />        

        </s:Skin>

这是我的申请

<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
                       xmlns:s="library://ns.adobe.com/flex/spark"
                       xmlns:mx="library://ns.adobe.com/flex/mx"
                       applicationComplete="fullScreen()"
                       width="910" height="728" 
                       skinClass="skins.uiskin">

    <fx:Declarations>

    </fx:Declarations>

    <fx:Script>
        <![CDATA[
            public function fullscreen():void{
                stage.displayState = StageDisplayState.FULL_SCREEN_INTERACTIVE;
                //hide button from here but how??
            }
        ]]>
    </fx:Script>
    <fx:Declarations>
        <!-- Place non-visual elements (e.g., services, value objects) here -->
    </fx:Declarations>
</s:WindowedApplication>
4

1 回答 1

1

try making a bindable boolean somewhere, where you store the fullscreenstate. then minimizebutton should have attributes includeinLayout and visible binded to it. (and maximize would be the opposite:

<s:Button id="minimizeButton"
                      skinClass="spark.skins.spark.windowChrome.MinimizeButtonSkin"
                      top="2" bottom="2" verticalCenter="0"
                      visible="{!isFullScreen}"
                      />
于 2013-04-10T13:06:55.393 回答