testTry-catch和catch中的应用程序恢复

testTry-catch和catch中的应用程序恢复

 

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
 <mx:Button x="10" y="10" id="btn1" label="showError" click="showError()" fontSize="12"/>
 <mx:Button x="10" y="63" label="Button" width="95" click="continueMute()" fontSize="12"/>


 <mx:Script>
  <![CDATA[
   import mx.controls.Alert;
   
   var tArr:Array;
   
   public function showError():void
   {     
     var aStr:String;
    
    try
    {
      aStr = tArr.toString();//tArr是个未初始化的数组,引用为null
     
    }
    catch (e:Error)
    {
        trace(e); // output: ArgumentError: Error #2024: An object may not be added as a child of itself.
     
     tArr = [];
     tArr.push("a");
     
     btn1.label = "xxx";
     Alert.show(e.toString());
     
     continueMute();
    }   
   }
   
   public function continueMute():void
   {  
    Alert.show("continueMute:" + tArr.toString());
   }
   
  ]]>
 </mx:Script>

 

 

 

 

 

 

 

 

 

 

 

 
</mx:Application>

posted on 2010-03-29 13:02  jiahuafu  阅读(211)  评论(0编辑  收藏  举报

导航