您好我正在使用 Flash Builder 4.6 为数据库创建应用程序和 AMFPHP 。我想在从AMFPHP检索数据时显示弹出窗口。并在执行完成后删除。
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
width="615" height="350" minWidth="955" minHeight="600">
<fx:Script>
<![CDATA[
import mx.controls.Alert;
import mx.rpc.events.ResultEvent;
import mx.utils.ArrayUtil;
protected function button1_clickHandler(event:MouseEvent):void
{
//i want to show popwindow for slow process
amf.readProduct();
}
protected function method1_resultHandler(event:ResultEvent):void
{
//Here the data is retrieved successfully then the popup is removed
myArraydata.removeAll();
myArraydata = new ArrayCollection(ArrayUtil.toArray(event.result));
}
]]>
</fx:Script>
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
<s:RemoteObject id="amf" source="your_source" destination="your_amf_destination"
endpoint="your_services" fault="{Alert.show(event.fault.faultDetail);}" showBusyCursor="true">
<s:method name="readProduct" result="method1_resultHandler(event)"/>
</s:RemoteObject>
<s:ArrayCollection id="myArraydata"/>
</fx:Declarations>
<s:Button x="10" y="10" label="Retrieve Data" click="button1_clickHandler(event)"/>
<mx:AdvancedDataGrid id="adg1" x="10" y="39" width="595" height="301" designViewDataType="flat">
<mx:columns>
<mx:AdvancedDataGridColumn dataField="col1" headerText="Column 1"/>
<mx:AdvancedDataGridColumn dataField="col2" headerText="Column 2"/>
<mx:AdvancedDataGridColumn dataField="col3" headerText="Column 3"/>
</mx:columns>
</mx:AdvancedDataGrid>
</s:Application>
答案 0 :(得分:1)
简单的想法是创建一个进度条&amp;将它加载到弹出窗口中(它也可以像加载一样传递消息....)。在单击按钮上创建弹出窗口,然后在绑定值时使用removeallPopups();
答案 1 :(得分:1)
另一种方法是在开始readProduct调用之前创建一个新的弹出窗口实例,并使用AsyncToken函数重新编译并在那里保存Popup实例。然后在结果处理程序中,您可以从ResultEvent.token对象中获取该实例,并仅关闭该实例。
protected function button1_clickHandler(event:MouseEvent):void
{
var popup:IFlexDisplayObject = PopUpManager.createPopup(this, MyPopupComonent, true);
//i want to show popwindow for slow process
var token:AsyncToken = amf.readProduct();
token.popup = popup;
}
protected function method1_resultHandler(event:ResultEvent):void
{
var popup:IFlexDisplayObject = IFlexDisplayObject(event.token.popup);
PopUpManager.removePopup(popup);
//Here the data is retrieved successfully then the popup is removed
myArraydata.removeAll();
myArraydata = new ArrayCollection(ArrayUtil.toArray(event.result));
}