Flex: 获得给定日期在其月份内为第几个day of week

Categories: Flex; Tagged with: ; @ June 28th, 2009 18:10
/*

 * All Rights Reserved
 * Changelog:
 * Li Guoliang - 2009-6-5: Initial version
 * @liguoliang.com
 */

  	/** 
  	 * 获得给定日期的是该月的第几个day of week. 如2009.6.28日, 为2009.06月的第四个周日, 则返回4.
  	 * @param date_  要计算周数的日期
	 * @return int 所在月的第几个周几.
	 */ 
	public static function getWeekOfMonth(date_:Date):int {
		var date:Date = new Date(date_.time);
		var month:int = date.month;
		var weekOfMonth:int = 0;

		while(true) {
			date.date -= 7;
			weekOfMonth ++;
			if(date.month != month) {
				break;
			}
		}
		
		return weekOfMonth;
	} 
	
	  /** 
  	 * 获得给定日期的是该月的倒数第几个day of week. 如2009.6.28日, 为2009.06月的倒数第一个[最后一个]周日, 则返回1.
  	 * @param date_  要计算周数的日期
	 * @return int 所在月的倒数第几个周day of week.
	 */ 
	public static function getWeekOfMonthFromLast(date_:Date):int {
		var date:Date = new Date(date_.time);
		var month:int = date.month;

		var weekOfMonthFromLat:int = 0;

		while(true) {
			date.date += 7;
			weekOfMonthFromLat ++;
			if(date.month != month) {
            	break;
			}
		}
		
		return weekOfMonthFromLat;
	}

Flex 图像处理: 黑白滤镜

Categories: Flex; Tagged with: ; @ May 28th, 2009 22:41

需求: 在某些时候, 如客户下线, 须将头像一类的图片变为黑白.

解决: 使用颜色矩阵滤镜.

效果: 如下图:

image

姓名后坠有"/黑白"[Absent]的图像为滤镜使用后的效果

使用方法:

当用户考勤状态为Present时:

//如果没有使用其他滤镜, 直接简写为:

_img.filters = [new ColorMatrixFilter([0.3086, 0.6094, 0.0820, 0, 0, 0.3086, 0.6094, 0.0820, 0,
0, 0.3086, 0.6094, 0.0820, 0, 0, 0, 0, 0, 1, 0])];

当状态为Absent时:

_img.filters = null;  // 去除黑白滤镜, 注意如果使用了其他滤镜, 则应单独从filters数组中除去黑白滤镜, 而不应直接设为null.

———————————-无关紧要的分割线—————————————–
另: new ColorMatrixFilter([0.3086, 0.6094, 0.0820, 0, 0, 0.3086, 0.6094, 0.0820, 0,
0, 0.3086, 0.6094, 0.0820, 0, 0, 0, 0, 0, 1, 0]) 的完整版:

var red:Number = 0.3086;
var green:Number = 0.694;
var blue:Number = 0.0820; //这三个值是提供标准的黑白效果
var cmf:ColorMatrixFilter = new ColorMatrixFilter(red, green, blue, 0, 0, red, green, blue, 0, 0, red, green, blue, 0, 0, 0, 0, 0, 1, 0);

Flex: 自适应大小TextArea, Resizable TextArea

Categories: Flex; Tagged with: ; @ May 8th, 2009 23:53

Flex3中: http://www.flexer.info/2009/02/06/auto-resizable-text-area-component/

Flex4 Spark组件已支持自适应高度: http://liguoliang.com/2010/auto-resizable-text-area-component/

Flex Int转String

Categories: Flex; Tagged with: ; @ April 24th, 2009 8:46

打印ABCD:

            	for(var i:int = 65; i < 69; i++) {
            		trace(String.fromCharCode(i));
            	}

结果:

A

B

C

D

Flex: 通过监听Event实现UI组件的Validation

Categories: Flex; Tagged with: ; @ April 23rd, 2009 14:28


textInputScore.addEventListener(Event.CHANGE, onTextInputScoreChange); // 监听Change事件
	// 检测成绩输入是否有效: 1. 必须为Number; 2. 必须小于最高分

		//if(isNaN(parseFloat(textInputScore.text))) { //错误, 形如2w之类将不报错....
		if(isNaN(Number(textInputScore.text))) {
			textInputScore.errorString = RM.getString(BUNDEL_ONLINETEST, "olt.grading.errorMessage.nan", [textInputScore.text]);
		}else if(parseFloat(textInputScore.text) > _questionAttempt.question.marksCorrrect) {
			textInputScore.errorString = RM.getString(BUNDEL_ONLINETEST, "olt.grading.errormessage.outScop", [textInputScore.text, _questionAttempt.question.marksCorrrect]);
		}else {
			textInputScore.errorString = null;
		}
	}

Newer Posts <-> Older Posts



// Proudly powered by Apache, PHP, MySQL, WordPress, Bootstrap, etc,.