如何让代码健壮

    今天不忙,看的东西也很简单,都是很基础的东西,继承,静态属性,getter setter私有属性等等……,这些都很基础,但是还是要利用不多的时间整理下,以提醒慢慢前进的自己,当然这些游戏不好做,周工也提出了新的要求,自己写方法替换原有的方法,下面归纳下周工教的东西。

    做的是一个时钟倒计时的方法,其中用到了自定义的图片做倒计时数字,显示隐藏时钟。

    用到了ImageNumber method

    var _timer:Timer = new Timer();//全局属性

    pirvate function startCountDown(seconds:int):void

    {   

         _timer.repeatCount = seconds //重复数

        _timer.addEventListener(TimerEvent.TIMER,onCountDown);

         _timer.addEventListener(TimerEvent.TIMER_COMPLETE,stopCountDown);

         _timer.start();

    }

    private function onCountDown(e:TimerEvent):void

    {

         if( ! this._clockShow)

              {

                  this._clockShow = new ImageNumber(14,19,new numImage2());

this.addChild(this._clockShow);

this._clockShow.y = -75;

}

addTTime.showClock();

this._clockShow.visible = true;

}

private function stopCountDown(e:TimerEvent):void

{

        this._clockShow.visible = false;

addTTime.hideClock();

}

posted @ 2011-10-09 17:17  独步寻花  阅读(181)  评论(0编辑  收藏  举报