在全屏Flex中隐藏最小化按钮

时间:2013-04-10 09:56:14

标签: flex actionscript skin

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

我的标题栏皮肤代码

<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>

1 个答案:

答案 0 :(得分:1)

尝试在某处创建一个可绑定的布尔值,在那里存储fullscreenstate。那么minimbutton应该有includeinLayout和visible绑定的属性。 (并且最大化将是相反的:

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