Chinaunix首页 | 论坛 | 博客
  • 博客访问: 695922
  • 博文数量: 160
  • 博客积分: 8847
  • 博客等级: 中将
  • 技术积分: 1656
  • 用 户 组: 普通用户
  • 注册时间: 2010-11-25 16:46
个人简介

。。。。。。。。。。。。。。。。。。。。。。

文章分类

全部博文(160)

文章存档

2015年(1)

2013年(1)

2012年(4)

2011年(26)

2010年(14)

2009年(36)

2008年(38)

2007年(39)

2006年(1)

分类:

2008-09-09 18:42:14


package {
    import flash.display.Sprite;
    [SWF(width="400",height="300",backgroundColor="#00ffee",frameRate="32")]
    public class actionscript3 extends Sprite
    {
        public function actionscript3():void {

        }
       
        //异常处理
        //try/throw/catch
        //当throw抛出异常时,会中断当前执行,自动寻找catch的语句块
        /*
        try{
            throw()
        }catch(){
       
        }final{
       
        }
        */
        public function drawRectangle(sprite:Sprite , nWidth:Number , nHeight:Number ):void{
                if (isNaN(nWidth) || isNaN(nHeight)){
                    throw new Error();
                }
               
                this.graphics.lineStyle(1,0,1);
                this.graphics.lineTo(nWidth,0);
                this.graphics.lineTo(nWidth,nHeight);
                this.graphics.lineTo(0,nHeight);
                this.graphics.lineTo(0,0);       
        }
    }
}

var _drawRectangle:actionscript3 = new actionscript3;
try{
    this.drawRectangle(this,2,3);
}catch(errObject:Error){
    trace("try again!!");
}finally{
    trace("thanks"); //finally语句,一定会被执行
}


结果如下:

阅读(1455) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~