Flex滚动条 [英] Flex ScrollBars

查看:84
本文介绍了Flex滚动条的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在为我的Flex应用程序显示滚动条时遇到问题...我尝试了一个基本的画布应用程序,但是尽管画布比屏幕上的尺寸大很多,但滚动条从未出现在浏览器窗口中.有人可以帮忙吗?这是我的代码:

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>

推荐答案

是否要在画布中使用滚动条?还是在您的主应用程序中?如果要在画布中使用滚动条,只需添加超出画布高度和宽度的内容即可.它将神奇地"添加它们,因为这就是MX/Halo组件的作用.

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:

    <?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">

<s:Scroller height="100" width="100">
 <s:Group width="100%" height="100%" clipAndEnableScrolling="true">
    <mx:Canvas id="MyCanvas" height="2500" width="2000" verticalScrollPolicy="auto" 
    horizontalScrollPolicy="auto" backgroundColor="black" symbolColor="#000000"
    contentBackgroundColor="#080808"/>

 </s:Group>

</s:Scroller>

    </s:Application>

以我的经验,您需要在滚动条上指定固定的高度和/或宽度,以便滚动条显示出来.另外,请确保将clipAndenableScrolling裁剪到滚动条上的组上,否则内容将显示在滚动条的视口之外,这有悖于此目的.

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.

来自Adobe的一些好信息.

这篇关于Flex滚动条的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆