Flex Hbox Creation完成未调用

时间:2013-02-26 10:20:14

标签: actionscript-3 flex flex4.5

我正在尝试创建Hbox的实例

obj = new HBox();
disp.addElement(obj); // disp object is border container but obj is mx component

这是我使用显示对象添加到父容器的方式。

但它不会调用创建完成事件。

过去几天我一直在努力。请帮帮我。

1 个答案:

答案 0 :(得分:0)

<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009" 
                       xmlns:s="library://ns.adobe.com/flex/spark" 
                       xmlns:mx="library://ns.adobe.com/flex/mx" initialize="windowedapplication1_initializeHandler(event)">
    <fx:Script>
        <![CDATA[
            import flash.sampler.NewObjectSample;

            import mx.containers.HBox;
            import mx.controls.Alert;
            import mx.events.FlexEvent;

            protected function windowedapplication1_initializeHandler(event:FlexEvent`enter code here`):void
            {
                var hbo:HBox=new HBox();
                hbo.addEventListener(FlexEvent.CREATION_COMPLETE,ff);
                b.addElement(hbo);
            }
            public function ff(e:FlexEvent):void
            {
                Alert.show("created")
            }

        ]]>`enter code here`
    </fx:Script>
    <fx:Declarations>
        <!-- Place non-visual elements (e.g., services, value objects) here -->
    </fx:Declarations>
    <s:Group id="b">

    </s:Group>
</s:WindowedApplication>