2010-01-11 54 views
1

我有一個自定義滾動條來控制一個組作爲它的視口。自動隱藏自定義滾動條Flex 4

<s:HGroup> 
     <s:Group width="520" height="380" clipAndEnableScrolling="true" id="descriptionBox" > 
      <s:RichText text="Test Test Test Test Test Test Test " 
         width="490" textAlign="justify" fontFamily="Arial" fontSize="12" color="#999999" /> 
     </s:Group> 
     <s:VScrollBar viewport="{descriptionBox}" 
       left="{descriptionBox.x + descriptionBox.width + 10}" 
       top="10" 
       height="{descriptionBox.height}" 
       fixedThumbSize="true" 
       skinClass="VScrollBarSkin"/> 
    </s:HGroup> 

我要作出這樣的滾動條自動隱藏,當該組的內容不超過視圖大小,任何想法如何做到這一點一般(意思是我不想依賴視口組內的部件上) ?

謝謝。

Flex中

回答

1

該滾輪部件正是如此:

  • Autohides /示出了在爲RenderingMode。GroupBase(集團或DATAGROUP,其IViewports)
  • 允許自定義通過皮膚滾動條水平和垂直滾動

這裏有一個會做你描述代碼:

<s:Application 
    xmlns="http://ns.adobe.com/mxml/2009" 
    xmlns:s="library://ns.adobe.com/flex/spark" 
    xmlns:mx="library://ns.adobe.com/flex/mx"> 

    <Script> 
     <![CDATA[ 

      private var times:int = 400; 

      private function updateText(type:String):void 
      { 
       var newText:String = ""; 
       var i:int = 0; 
       var n:int = times; 
       for (i; i < n; i++) 
       { 
        newText += "Test "; 
       } 
       var text:String = richText.text; 
       if (type == "add") 
        text += newText; 
       else 
        text = newText.replace(text) + ''; 
       richText.text = text; 
      } 

     ]]> 
    </Script> 
    <s:HGroup> 
     <s:Button label="+" click="updateText('add')"/> 
     <s:Button label="-" click="updateText('remove')"/> 
    </s:HGroup> 
    <s:Scroller width="520" height="380" id="scroller" minViewportInset="1" focusEnabled="false"> 
     <s:Group clipAndEnableScrolling="true" id="descriptionBox"> 
      <s:RichText id="richText" creationComplete="updateText('add')" 
       width="490" textAlign="justify" fontFamily="Arial" fontSize="12" color="#999999" /> 
     </s:Group> 
    </s:Scroller> 
</s:Application> 

您不想在組上添加明確的寬度/高度,因爲它取決於其孩子的尺寸。如果您將其包裝在Scroller中,它會處理您的所有細節。

如果要定製這些元素上的圖形,可以查看VScrollBarSkin,VScrollBarThumb,VScrollBarTrack等。如果你不想要水平滾動條,你可以不把它包含在你的MyScrollerSkin類中。

希望幫助, 蘭斯

+0

您好,感謝您的答覆,我沒有看到在那裏的任何代碼? – shipmaster 2010-01-12 17:10:34

+0

是否解決了這個問題? – 2010-02-20 03:48:02

+0

是的,謝謝。 – shipmaster 2010-03-02 22:22:18