我这样做:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application initialize="onLoad()"...>
<mx:Button id="connect_btn" />
<mx:Script>
<![CDATA[
public function onLoad():void
{
connect_btn.click();
}
]]>
</mx:Script>
</mx:Application>
但是得到connect_btn
未定义的错误......
更新
是的,我正在尝试模拟点击事件。
答案 0 :(得分:2)
您可以这样发送:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application initialize="onLoad()"...>
<mx:Button id="connect_btn" />
<mx:Script>
<![CDATA[
public function onLoad():void
{
var e:MouseEvent = new MouseEvent(MouseEvent.CLICK);
connect_btn.dispatchEvent(e);
}
]]>
</mx:Script>
</mx:Application>