滚动条换肤问题

发布于 2024-08-24 22:34:48 字数 324 浏览 8 评论 0原文

我正在我的 Flex 应用程序中剥皮滚动条,但遇到了一个问题。 滚动条之间的这个白色方块(查看图像)破坏了我所有的设计,我需要禁用它,使其不可见,更改它的背景颜色,alpha 或类似的东西。

我可以在这里粘贴一些代码,但我认为没有必要。 在 Flex 3 中工作。 有什么想法吗?

替代文本 http://img97.imageshack.us/img97/9206/scrollbar.png< /a>

I'm skinning scrollbar in my flex app and got one problem.
This white square between scrollbars(view the image) ruibs all my design and i need to disable it, make it invisible, change it background color, alpha or smth like this.

I can paste some code here but i think there is no need in it.
Working in Flex 3.
any ideas?

alt text http://img97.imageshack.us/img97/9206/scrollbar.png

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

好菇凉咱不稀罕他 2024-08-31 22:34:49

我实际上在 Flex 框架内部找到了罪魁祸首。
这个正方形(称为 whiteBox)是在 Container.as 中创建的。

摆脱它非常容易,您只需创建一个扩展您要使用的容器的类即可。

画布示例:

package
{
    import mx.containers.Canvas;

    public class NoWhiteBoxCanvas extends Canvas
    {

        public function NoWhiteBoxCanvas()
        {
            super();
        }

        override public function validateDisplayList():void
        {
            super.validateDisplayList();
            this.whiteBox.visible = false;
        }

    }
}

然后在您的 MXML 中:

<local:NoWhiteBoxCanvas width="300" height="300" horizontalScrollPolicy="on" verticalScrollPolicy="on"/>

...然后就不再有白色方块了;)

I actually found the culprit looking inside the Flex framework.
This square (called whiteBox) is created in Container.as.

It's pretty easy to get rid of it, you just have to create a class extending the container you want to use.

Exemple for a Canvas :

package
{
    import mx.containers.Canvas;

    public class NoWhiteBoxCanvas extends Canvas
    {

        public function NoWhiteBoxCanvas()
        {
            super();
        }

        override public function validateDisplayList():void
        {
            super.validateDisplayList();
            this.whiteBox.visible = false;
        }

    }
}

Then in your MXML:

<local:NoWhiteBoxCanvas width="300" height="300" horizontalScrollPolicy="on" verticalScrollPolicy="on"/>

...and then no white square anymore ;)

泛滥成性 2024-08-31 22:34:49

您是否尝试过

background-alpha: 0.0;

在获取滚动条的容器上进行设置?它应该让容器的矩形拾取父级的颜色。

Have you tried setting

background-alpha: 0.0;

on the container that is getting the scrollbars? It should let the rect of the container pick up the color of the parent then.

俯瞰星空 2024-08-31 22:34:49

一个肮脏的伎俩是使用遮罩来隐藏该方块。
像这样的:

<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="creationComplete()">

    <mx:Script>
        <![CDATA[
            import mx.core.UIComponent;

            public function creationComplete():void
            {
                var compMask:UIComponent = new UIComponent;
                compMask.graphics.beginFill( 0xff0000 );
                compMask.graphics.drawRect( 0, 0, comp.width, comp.height - 16 );
                compMask.graphics.drawRect( 0, comp.height - 16, comp.width - 16, 16 );
                compMask.graphics.endFill();
                addChild( compMask );
                comp.mask = compMask;
            }
        ]]>
    </mx:Script>

    <mx:Canvas id="comp" width="300" height="300" horizontalScrollPolicy="on" verticalScrollPolicy="on"/>

</mx:WindowedApplication>

刚刚尝试过,它有效。每次调整组件大小时,您只需重新绘制蒙版。最好的办法是创建一个扩展 Canvas 的自定义类并自行完成工作。

编辑:当然,如果值不同,您将需要根据自定义滚动条的权重更改“16”。

One dirty trick would be to use a mask to hide that square.
Something like this :

<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="creationComplete()">

    <mx:Script>
        <![CDATA[
            import mx.core.UIComponent;

            public function creationComplete():void
            {
                var compMask:UIComponent = new UIComponent;
                compMask.graphics.beginFill( 0xff0000 );
                compMask.graphics.drawRect( 0, 0, comp.width, comp.height - 16 );
                compMask.graphics.drawRect( 0, comp.height - 16, comp.width - 16, 16 );
                compMask.graphics.endFill();
                addChild( compMask );
                comp.mask = compMask;
            }
        ]]>
    </mx:Script>

    <mx:Canvas id="comp" width="300" height="300" horizontalScrollPolicy="on" verticalScrollPolicy="on"/>

</mx:WindowedApplication>

Just tried it, it works. You'll just have to redraw the mask each time the component is resized. Best thing would be to create a custom class which extends Canvas and do the job itself.

EDIT: Of course, you will want to change "16" by the weight of your custom scrollbars if the value is different.

会傲 2024-08-31 22:34:49

您已经有了一个很好的答案,但另一种选择是手动管理滚动条。您可以将滚动条放置在应用程序中的任何位置,并将其绑定以滚动您想要的控件。这样做,您可以有效地让垂直滚动条拉伸那些额外的 16 个像素以覆盖白框。请注意,只有在保证始终需要滚动条的情况下我才会这样做。最终看起来会像我在这里绘制的非常糟糕的文字:

          |  |
          |  |
__________|__|
_______| >|\/|

You already have a good answer but another alternative is to manually manage your scrollbars. You can put a scrollbar anywhere in your app and bind it to scroll the control you want. Doing this you could effectively get the vertical scroll bar to stretch those extra 16 pixels to cover the whitebox. Note that I would only do this if it were guaranteed to always need a scrollbar. Would kind of end up looking like my really bad text drawing here:

          |  |
          |  |
__________|__|
_______| >|\/|
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文