Flex中有没有blocking?

王朝other·作者佚名  2006-01-09
宽屏版  字体: |||超大  

最近在看Flex的groups中发现有一个以前遇到的问题,但是没有意识到的问题。当我在一个函数中发出httpservice,然后加入一个事件的监听处理httpservice返回的值,后面如果还有代码回马上执行,并不会等处理完httpservice返回再进行。是我的代码有问题还是Flex本身就是这样的呢?刚刚看到Group里的一个贴子说在ActionScript中没有真正意义上的Blocking,用Alert,并且配合shoumodel模式来实现阻止用户继续和界面交互。这样对于我刚刚遇到的问题没有什么帮助,可以尝试在处理httpservice返回函数设置返回值,调用函数根据这个返回值进行下一步的操作。

There is no true blocking in ActionScript. Both alerts and modal pop-ups only

stop the user from interacting with the UI. All code continues to execute to

the end.

To do what you want, you need to have a two part approach, where you call the

confirmation dialog first, then, when that is dismissed, take the actual action.

Below is an example using an alert. In my application, is use a modal pop-up

so that I can have more control.

Tracy

<?xml version="1.0" encoding="utf-8"?>

<mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml">

<mx:Script><![CDATA[

private function doAction(sAction:String):Void

{

alert(sAction,

"Confirm Action",

mx.controls.Alert.YES|mx.controls.Alert.NO,

handleConfirm,

mx.controls.Alert.NO)

}//

private function handleConfirm(oEvent:Object):Void

{

switch(oEvent.detail)

{

case 1:

alert("The Action was Confirmed")

break;

case 2:

alert("The Action was Canceled")

break;

}//switch()

}//

]]></mx:Script>

<mx:Button label="Do Some Action" click="doAction('delete')"/>

</mx:Application>

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
© 2005- 王朝网络 版权所有