Actionscript 3 Flex中奇怪的滚动条行为
当我执行以下应用程序时,我的Actionscript 3 Flex中奇怪的滚动条行为,actionscript-3,apache-flex,Actionscript 3,Apache Flex,当我执行以下应用程序时,我的滚动条一直延伸到内部组的高度 <?xml version="1.0" encoding="utf-8"?> <s:Application xmlns:s="library://ns.adobe.com/flex/spark" xmlns:fx="http://ns.adobe.com/mxml/2009"> <s:Scroller width="100%" height="100%" verticalScrollPolicy="
滚动条一直延伸到内部组的高度
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:s="library://ns.adobe.com/flex/spark" xmlns:fx="http://ns.adobe.com/mxml/2009">
<s:Scroller width="100%" height="100%" verticalScrollPolicy="on">
<s:Group height="1400"/>
</s:Scroller>
</s:Application>
以下是我得到的:
我希望它和我的窗户一样大。
请你解释一下,我做错了什么?为什么滚动条不充当视口?通常,您希望将滚动条的高度/宽度设置为显式值,并将子项的高度/宽度设置为百分比。你做的正好相反。那么像这样,
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:s="library://ns.adobe.com/flex/spark" xmlns:fx="http://ns.adobe.com/mxml/2009">
<s:Scroller width="100%" height="1400" verticalScrollPolicy="on">
<s:Group height="100%"/>
</s:Scroller>
</s:Application>
但是,这并不能解决使滚动条/组成为可用窗口宽度的问题。我可以通过在updateDisplayList()方法中调整元素的大小来做到这一点
受保护的函数updateDisplayList(unscaledWidth:Number,unscaledHeight:Number:void{
super.updateDisplayList(unscaledWidth、unscaledHeight);
myScroller.width=未标度宽度;
myScroller.height-无刻度高度;
mySCrollingGroup.width=unscaledWidth
mySCrollingGroup.height-未标度高度;
}
您可能需要调整myScrollingGroup的大小以适应滚动条的高度/宽度。或者,您可以使用myScrollingGroup上的前八个/percentWidth属性并将其设置为100%。谢谢!当我在updatedDisplayList函数中设置myScroller.percentHeight时,它工作得很顺利!
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:s="library://ns.adobe.com/flex/spark" xmlns:fx="http://ns.adobe.com/mxml/2009">
<fx:Script>
protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number:void{
super.updateDisplayList(unscaledWidth, unscaledHeight);
myScroller.width = unscaledWidth;
myScroller.height - unscaledHeight;
mySCrollingGroup.width = unscaledWidth
mySCrollingGroup.height - unscaledHeight;
}
</fx:Script>
<s:Scroller verticalScrollPolicy="on" id="myScoller">
<s:Group id="mySCrollingGroup" />
</s:Scroller>
</s:Application>