【问题标题】:Can't set backgroundColor property of container in FLEX无法在 FLEX 中设置容器的 backgroundColor 属性
【发布时间】:2013-05-29 09:52:10
【问题描述】:
var newHBox:VBox = new VBox();
newHBox['width'] = 20;
newHBox['height'] = 30;
newHBox['backgroundColor'] = "#FF0000";
container.addChild(newHBox);

var newHBox:VBox = new VBox();
newHBox.width = 20;
newHBox.height = 30;
newHBox.backgroundColor = "#FF0000";
container.addChild(newHBox);

我不明白为什么我不能设置backgroundColor 属性,我得到一个错误:

access of possibly undefined property through a reference with static type mx.containers.VBox

如果我使用第一个代码示例,那么没有错误,但背景颜色仍然不适用,styleName 应用良好,你能告诉我为什么背景颜色不能设置吗?

【问题讨论】:

标签: apache-flex actionscript mxml


【解决方案1】:

backgroundColor 是一个样式属性,所以你应该使用:

newHBox.setStyle("backgroundColor", 0xFF0000);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-12-19
    • 2021-10-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-11-02
    相关资源
    最近更新 更多