【永恒的瞬间】
☜Give me hapy ☞
在MXML的页面中,使用了http返回参数中没有定义的变量,并没有显示报错信息,而是显示了underfined。我用在text的显示和输入界面里了,如果用在tree或者其他的变量可能就报错了。所以还是定义一个函数专门处理返回的参数能够使程序更健壮吧!


近在看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>

posted on 2007-01-12 16:00 ☜♥☞MengChuChen 阅读(199) 评论(0)  编辑  收藏

只有注册用户登录后才能发表评论。


网站导航: