0

我正在尝试创建一个Hbox类似的实例

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

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

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

最近几天我一直在努力。请帮我。

4

1 回答 1

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>
于 2013-02-28T10:38:51.267 回答