/** * 获取文字的明暗值 * @param t 文字 * @return Number */ function getDensity(t:String):Number { var ttf:TextField = new TextField ; ttf.autoSize = TextFieldAutoSize.LEFT; ttf.text = t; var bmd:BitmapData = new BitmapData(ttf.width,ttf.height,false,0xffffff); bmd.draw(ttf); var c:int = 0; for (var x:int = 0; x < bmd.width; x++) { for (var y:int = 0; y < bmd.height; y++) { if (bmd.getPixel(x,y) != 0xffffff) { c++; } } } return c / ttf.width / ttf.height; }