20110418(Flex)

在SDK4中控制滚动条的方式有所变更,

不再沿用flex3中的两个属性verticalScrollPolicy,horizontalScrollPolicy

1.浏览器滚动条显示与否。

如果浏览器的尺寸是1024×768,Application的长度,宽度设为100%,即使应用程序的尺寸大于1024*768也不会出现滚动条。

如果浏览器的尺寸是1024×768,Application的长度,宽度设为1924*1080,浏览器会出现滚动条。

2.对于一般的控件想让其出现滚动条,可以用<s:Scroller/>

在Tour de Flex中有以下示例

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="
library://ns.adobe.com/flex/spark"
xmlns:mx="
library://ns.adobe.com/flex/mx"
viewSourceURL="
srcview/index.html">


<s:Panel width="100%" height="100%"
      title="
Scroller Sample">
<s:VGroup horizontalCenter="0">
<s:HGroup>
<s:Label text="Min Viewport Inset:"/>
<s:HSlider id="slider1"
maximum="
50"
liveDragging="
true" />
<s:Label text="Viewport Width:"/>
<s:HSlider id="slider2"
minimum="
100"
maximum="
550"
value="
300"
liveDragging="
true" />
<s:Label text="Viewport Height:"/>
<s:HSlider id="slider3"
minimum="
100"
maximum="
550"
value="
200"
liveDragging="
true" />
</s:HGroup>
<s:HGroup>
<s:Scroller id="scroller"
minViewportInset="
{slider1.value}"
width="
300" height="200">
<s:Group>
<s:Rect id="rect"
width="
{slider2.value}"
height="
{slider3.value}">
<s:fill>
<s:LinearGradient rotation="45">
<s:GradientEntry color="red" />
<s:GradientEntry color="yellow" />
<s:GradientEntry color="haloBlue" />
</s:LinearGradient>
</s:fill>
</s:Rect>
</s:Group>
</s:Scroller>
<s:Label textAlign="justify" width="280" verticalAlign="justify"
text="
The Scroller control contains a pair of scroll bars and a viewport. A viewport displays a rectangular subset of the area of
a component, rather than displaying the entire component. You can use the Scroller control to make any container that implements the IViewport interface,
such as Group, scrollable. The Scroller's horizontal and vertical scroll policies are set to auto which indicates that scroll bars are displayed when the
content within a viewport is larger than the actual size of the viewport.
"/>
</s:HGroup>
</s:VGroup>
</s:Panel>

</s:Application>

posted @ 2011-04-18 14:37  寻眸哥  Views(199)  Comments(0)    收藏  举报