2004/12/18 | 再次练习写类——签名类
类别(Flash习作) | 评论(4) | 阅读(301) | 发表于 23:56
//显示字符(字串型压缩数据)
class _jh7086 {
    public function _jh7086(interval, s, ox, oy, dat) {
        dat = dat != null ? dat : "l17DLQVbj,2456789AEGHIJKLMOPQRSTVXcefghijk,26CLVXaj,69CHLPQRSUVWXYafj,0159CHLPSVafj,145678CHLPSVafj,17ACGILPQRSVWaegj,169CFJLPRVWadhj,1358CEKLPRSUWYacij,12679CLORUWYaj,45ACJKLQRTWXYahij";
        s = s != null ? s : 1;
        ox = ox != null ? ox : 0;
        oy = oy != null ? oy : 0;
        var kkk = 20000;
        var width = jh_Dto10(dat.charAt(0),62);
        dat = dat.slice(1);
        dat = dat.split(",");
        var height = dat.length;
        var depth = _root.getNextHighestDepth();
        var mc = _root.createEmptyMovieClip("jh_"+depth, depth);
        mc._x = ox+2*s;
        mc._y = oy+2*s;
        mc.onRelease = function() {
            getURL("http://www.5dblog.com/user2/jh7086", "_blank");
        };
        showme();
        var tt = interval != null ? setInterval(showme, interval) : null;
        //填字
        function showme() {
            mc.clear();
            box(mc, -2*s, -2*s, width*s+2*s, height*s+2*s);
            var str, L, i, j;
            for (i=0; i<height; i++) {
                str = dat[i];
                L = str.length;
                while (str.length>0) {
                    j = jh_Dto10(str.charAt(0),62);
                    str = str.slice(1);
                    var sx = j*s, sy = i*s;
                    var ex = (j+1)*s, ey = (i+1)*s;
                    var col = random(50)+150;
                    col = (col+50)*256*256+col*256+150;
                    box(mc, sx, sy, ex, ey, col);
                }
            }
        }
        //将D进制数转换为10进制
        function jh_Dto10(str, d) {
            var code = 0, num = 0;
            for (var i = 0; i<str.length; i++) {
                code = str.charCodeAt(i);
                if (code>96) {
                    code -= 61;
                } else if (code>64) {
                    code -= 55;
                } else {
                    code -= 48;
                }
                num += code*Math.pow(d, str.length-1-i);
            }
            return num;
        }
        //绘制矩形填充块
        function box(mc, sx, sy, ex, ey, col, alp) {
            col = col != null ? col : 0;
            alp = alp != null ? alp : 100;
            mc.lineStyle();
            mc.beginFill(col, alp);
            mc.moveTo(sx, sy);
            mc.lineTo(sx, ey);
            mc.lineTo(ex, ey);
            mc.lineTo(ex, sy);
            mc.lineTo(sx, sy);
            mc.endFill();
        }
    }
}
0

评论Comments