在MXML的頁面中,使用了http返回參數(shù)中沒有定義的變量,并沒有顯示報(bào)錯(cuò)信息,而是顯示了underfined。我用在text的顯示和輸入界面里了,如果用在tree或者其他的變量可能就報(bào)錯(cuò)了。所以還是定義一個(gè)函數(shù)專門處理返回的參數(shù)能夠使程序更健壯吧!
近在看Flex的groups中發(fā)現(xiàn)有一個(gè)以前遇到的問題,但是沒有意識(shí)到的問題。當(dāng)我在一個(gè)函數(shù)中發(fā)出httpservice,然后加入一個(gè)事件的監(jiān)聽處理httpservice返回的值,后面如果還有代碼回馬上執(zhí)行,并不會(huì)等處理完httpservice返回再進(jìn)行。是我的代碼有問題還是Flex本身就是這樣的呢?剛剛看到Group里的一個(gè)貼子說在ActionScript中沒有真正意義上的Blocking,用Alert,并且配合shoumodel模式來實(shí)現(xiàn)阻止用戶繼續(xù)和界面交互。這樣對(duì)于我剛剛遇到的問題沒有什么幫助,可以嘗試在處理httpservice返回函數(shù)設(shè)置返回值,調(diào)用函數(shù)根據(jù)這個(gè)返回值進(jìn)行下一步的操作。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 閱讀(222)
評(píng)論(0) 編輯 收藏