【问题标题】:flash as3 - bit101 component window background colorflash as3 - bit101 组件窗口背景颜色
【发布时间】:2012-03-08 17:52:57
【问题描述】:

我在 as3 中为 flash 使用 bit101 组件,并且我有一个白色背景色的窗口。我想让那个颜色半透明。如果我为窗口设置 alpha,则窗口内的所有内容也是半透明的。我只想要背景。我该如何做到这一点?这是我的代码:

window = new Window(square, 10, 10, 'ADVANCED\t\t\t\t\t\t\t Use spacebar to randomize values');
            window.width = 380;
            window.height = 140;
            window.hasMinimizeButton = true;
            window.shadow = false;
            window.minimized = true;
            window.addEventListener(Event.RESIZE, onWindowResizeHandler, false, 0, true);
            window.color = 0xFFFFFF;

【问题讨论】:

    标签: actionscript-3 flash components


    【解决方案1】:

    快速查看源代码,Window 似乎包含一个 PanelPanel 包含一个受保护的 _background 对象。

    https://github.com/minimalcomps/minimalcomps/blob/master/src/com/bit101/components/Panel.as

    override public function draw():void
    {
        super.draw();
        _background.graphics.clear();
        _background.graphics.lineStyle(1, 0, 0.1);
        if(_color == -1)
        {
            _background.graphics.beginFill(Style.PANEL);
        }
        else
        {
            _background.graphics.beginFill(_color);
        }
        _background.graphics.drawRect(0, 0, _width, _height);
        _background.graphics.endFill();
        ...
    

    我会尝试扩展WindowPanel 类,并以某种方式添加指定backgroundAlpha 属性的能力,这将是上面beginFill() 的第二个参数。看起来工作量很大。

    似乎没有更直接的方法可以做到这一点。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-07-08
      • 2012-02-15
      • 1970-01-01
      • 2012-02-05
      • 2013-07-04
      • 1970-01-01
      • 2010-12-03
      • 2022-11-17
      相关资源
      最近更新 更多