我正在尝试创建Hbox
的实例
obj = new HBox();
disp.addElement(obj); // disp object is border container but obj is mx component
这是我使用显示对象添加到父容器的方式。
但它不会调用创建完成事件。
过去几天我一直在努力。请帮帮我。
答案 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>