Flex 滚动条
我在显示 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" minWidth="955" minHeight="600">
<mx:Canvas id="MyCanvas" height="2500" width="2000" verticalScrollPolicy="auto"
horizontalScrollPolicy="auto" backgroundColor="black" symbolColor="#000000"
contentBackgroundColor="#080808"/>
</s:Application>
I have a problem displaying scrollbars for my Flex Application... I tried a basic very application with a canvas, but the scrollbars never appear on the browser window athough the canvas is much bigger than what can fit on the screen. Can someone please help? Here's my code :
<?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" minWidth="955" minHeight="600">
<mx:Canvas id="MyCanvas" height="2500" width="2000" verticalScrollPolicy="auto"
horizontalScrollPolicy="auto" backgroundColor="black" symbolColor="#000000"
contentBackgroundColor="#080808"/>
</s:Application>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您想要画布中的滚动条吗?或者在你的主应用程序中?如果您希望画布中出现滚动条,只需添加超出画布高度和宽度的内容即可。它将“神奇地”添加它们,因为这就是 MX/Halo 组件的作用。
如果您希望在主应用程序中使用滚动条,则必须使用滚动器组件和组手动添加它们。从概念上讲是这样的:
根据我的经验,您需要在滚动条上指定固定的高度和/或宽度才能显示滚动条。还要确保在滚动条内的组上进行 ClipAndenableScrolling,否则内容将显示在滚动条的视口之外 - 这有点违背了目的。
来自 Adobe 的一些好信息。
Do you want the scroll bar in your canvas? Or in your main application? If you want scroll bars in your canvas, just add content that extends beyond the height and width of the canvas. It will "magically" add them, because that is way MX/Halo components role.
If you want scrollbars in your main application, you're going to have to add them manually, using a scroller component and a group. Conceptually something like this:
In my experience you need to specify a fixed height and/or width on the scroller for the scroll bars to show up. Also be sure to clipAndenableScrolling on the group inside the scroller, or else the content will display beyond the scroller's viewport--which is kind of defeats the purpose.
Some good info from Adobe.
我使用我的应用程序 mxml 周围的滚动器/组让它工作得很好,我尝试了其他人的滚动器皮肤定义,但它不起作用。
最主要的是将应用程序、滚动条和滚动条的所有高度和宽度设置为 100%。团体。
I got it to wrok just fine using the scroller/group around my applications mxml, i tried someone elses scroller skin def but it didnt work.
the main thing is to set all the heights and widths to 100% for the application, scroller & group.
在 Flex 4+ (spark) 中,您不再使用“scrollPolicies”。 MX 画布仍然如此,因此如果画布内容超出 2500x2000,它们将会滚动。
为了使整个应用程序具有滚动条,您需要为应用程序创建一个皮肤并将“contentGroup”包装在标签中。
请参阅:http://help.adobe.com/en_US/flex/using/WS2db454920e96a9e51e63e3d11c0bf62d75-7fff.html 了解有关向 Spark 应用程序添加滚动条的更多信息
In Flex 4+ (spark) you don't use "scrollPolicies" anymore. The MX canvas still does, so if your canvas contents grow beyond 2500x2000, they will scroll.
For your entire APP to have a scroller you need to create a skin for the Application and wrap the "contentGroup" in a tag.
See: http://help.adobe.com/en_US/flex/using/WS2db454920e96a9e51e63e3d11c0bf62d75-7fff.html for more information on adding a scroller to a spark application