Actionscript 3 动作脚本3,动作脚本中的网格和网格行

Actionscript 3 动作脚本3,动作脚本中的网格和网格行,actionscript-3,apache-flex,actionscript,flex4,Actionscript 3,Apache Flex,Actionscript,Flex4,我想在Flex中创建一个表,其中包含子节、colspan和rowsan我已经用flex中的硬编码构建了它,但我想用动作脚本动态构建它我真的不知道如何构建它。 这是我需要转换为动作脚本的示例代码 <mx:Grid id="metricsGrid" styleName="grid" backgroundColor="blue" horizontalAlign="center" width="100%" height="100%"> <mx:GridRow id="cashM

我想在Flex中创建一个表,其中包含子节、colspan和rowsan
我已经用flex中的硬编码构建了它,但我想用动作脚本动态构建它

我真的不知道如何构建它。 这是我需要转换为动作脚本的示例代码

<mx:Grid id="metricsGrid" styleName="grid" backgroundColor="blue" horizontalAlign="center" width="100%" height="100%">
    <mx:GridRow id="cashMetricsGridHeaderRow" >
        <mx:GridItem colSpan="3" styleName="gridItem" verticalAlign="middle" horizontalAlign="center" >
            <mx:Label text="{ getTodaysDateWithTitle() }" styleName="boldFontWeight"></mx:Label>
        </mx:GridItem>
    </mx:GridRow>

    <mx:GridRow id="metricsGridRow1" borderColor="black">
        <mx:GridItem rowSpan="3" styleName="gridItem" verticalAlign="middle" horizontalAlign="center" >
            <mx:Label text="ABC" height="50" styleName="boldFontWeight"></mx:Label>
        </mx:GridItem>
        <mx:GridItem rowSpan="3" styleName="gridItem" verticalAlign="bottom" horizontalAlign="center" >
            <mx:Label text="Total" height="50" styleName="boldFontWeight"></mx:Label>
        </mx:GridItem>
        <mx:GridItem rowSpan="3" styleName="gridItem" verticalAlign="middle" horizontalAlign="center" >
            <mx:Label text="XYZ" styleName="boldFontWeight"></mx:Label>
        </mx:GridItem>
    </mx:GridRow>
</mx:Grid>

如果您需要任何其他信息,请告诉我。
非常感谢你的帮助。谢谢。

以下内容应该可以让您开始学习。从
createChildren()
覆盖或
初始化
事件侦听器调用
createGrid()

请注意,这里声明的变量可能需要是类变量,以便于访问

private function createGrid() {
    var metricsGrid:Grid = new Grid();
    //set other properties on metricsGrid

    var cashMetricsGridHeaderRow:GridRow = new GridRow();
    //set other properties on metricsGrid

    var item:GridItem = new GridItem();
    //set other properties on GridItem

    var label:Label = new Label();
    label.text = getTodaysDateWithTitle();

    item.addElement(label);
    cashMetricsGridHeaderRow.addElement(item);
    metricsGrid.addElement(cashMetricsGridHeaderRow);

    this.addElement(grid);
}