2013-04-10 80 views
1

我有一個帶有自定義皮膚的窗口應用程序,皮膚包含標題欄,它也使用自定義皮膚。現在問題是如果窗口設置爲全屏,我需要動態地隱藏最小化和最大化按鈕。請幫助...全屏隱藏最小化按鈕Flex

我的標題欄的皮膚代碼

<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

嘗試進行綁定布爾某處,在那裏你存儲全屏狀態。那麼最小化按鈕應該具有包含inLayout和綁定到它的可見的屬性。 (並且最大化將是相反的:

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