方块颜色由深变浅、由浅变深循环

import flash.events.Event;

addEventListener(Event.ENTER_FRAME,_enter);

var _flag:Boolean=true;
function _enter(e:Event):void {
	if (_flag) {
		_rect.alpha+=(0-_rect.alpha)*0.2;
		if (_rect.alpha<0.05) {
			_rect.alpha=0;
			_flag=false;
		}
	} else {
		_rect.alpha+=(1-_rect.alpha)*0.2;
		if (_rect.alpha>0.98) {
			_rect.alpha=1;
			_flag=true;
		}
	}
}

转载于:https://www.cnblogs.com/leon3286/archive/2010/05/27/1745054.html

你可能感兴趣的:(方块颜色由深变浅、由浅变深循环)