快速业务通道

用纯AS写滚动条

作者 佚名技术 来源 服务器技术 浏览 发布时间 2012-07-08

前两个星期抽时间看了看一直很感兴趣却没时间研究的XML类和绘图API
觉得也没之前想象的那么神秘:) 用了三个晚自习的时间用AS1.0写了这个纯AS+XML的滚动条,算做练习吧。
请高手多多指教! 下面是所有的AS代码: //%%%%%%%%%%%%MC类自定义方法%%%%%%%%%%%%//
//——————绘图方法————//
//三角型方法
MovieClip.prototype.sanjiaoxing = function(zuobiao1, zuobiao2, zuobiao3, bangzhi, yanse, toumingdu) {
this.lineStyle(bangzhi, yanse, toumingdu);
this.moveTo(zuobiao1.x, zuobiao1.y);
this.lineTo(zuobiao2.x, zuobiao2.y);
this.lineTo(zuobiao3.x, zuobiao3.y);
this.lineTo(zuobiao1.x, zuobiao1.y);
};
//宽高矩形法,根据初始点坐标和宽与高确定矩形。x,y为初始点坐标,kuan和gao为矩形的宽和高。
MovieClip.prototype.changkuanjuxing = function(x, y, kuan, gao, bangzhi, yanse, toumingdu) {
this.lineStyle(bangzhi, yanse, toumingdu);
this.moveTo(x, y);
this.lineTo(x+kuan, y);
this.lineTo(x+kuan, y+gao);
this.lineTo(x, y+gao);
this.lineTo(x, y);
};
//中心点矩形法,根据中心点的坐标和宽与高确定矩形。x,y为中心点坐标,kuan,gao为矩形的长和宽。
MovieClip.prototype.zhongxinjuxing = function(x, y, kuan, gao, bangzhi, yanse, toumingdu) {
this.lineStyle(bangzhi, yanse, toumingdu);
this.moveTo(x-kuan/2, y+gao/2);
this.lineTo(x+kuan/2, y+gao/2);
this.lineTo(x+kuan/2, y-gao/2);
this.lineTo(x-kuan/2, y-gao/2);
this.lineTo(x-kuan/2, y+gao/2);
};
//————定位方法————//
MovieClip.prototype.dingwei = function(x, y) {
this._x = x;
this._y = y;
};
//————上色方法————//
//定义一个获取颜色值,并把它转化成16进制的函数
//获取颜色值的后六位,使此方法可以同时满足“#FFFFFF”和“0xFFFFFF”两种格式的颜色值
function jinzhizhuanhuan(yansezhi) {
var yansezhi = yansezhi.substr(-6, 6);
return parseInt(yansezhi, 16);
}
Color.prototype.shangse = function(yansezhi) {
this.setRGB(jinzhizhuanhuan(yansezhi));
};
MovieClip.prototype.shangse = function(yansezhi) {
var linshi_color = new Color(this);
linshi_color.shangse(yansezhi);
};
//%%%%%%%%%%%加载XML文档%%%%%%%%%%%%%//
gundongtiao_xml = new XML();
gundongtiao_xml.ignoreWhite = true;
gundongtiao_xml.load("gundongtiao.xml");
gundongtiao_xml.onLoad = function() {
var jiedianlujing_xml = gundongtiao_xml.firstChild.childNodes;
//滚动条背景参数
with (jiedianlujing_xml[0]) {
var gundongtiaobeijingse = jinzhizhuanhuan(attributes["背景色"]);
var gundongtiaotoumingdu = attributes["背景透明度"];
var gundongtiaobiankuangse = jinzhizhuanhuan(attributes["边框色"]);
var gundongtiaobiankuangtoumingdou = attributes["边框透明度"];
var gundongtiaobiankuangcuxi = attributes["边框粗细"];
var gundongtiaokuan = attributes["宽"];
}
//方块参数
with (jiedianlujing_xml[1]) {
var fangkuaibeijingse = jinzhizhuanhuan(attributes["背景色"]);
var fangkuaitoumingdu = attributes["背景透明度"];
var fangkuaibiankuangse = jinzhizhuanhuan(attributes["边框色"]);
var fangkuaibiankuangtoumingdou = attributes["边框透明度"];
var fangkuaibiankuangcuxi = attributes["边框粗细"];
}
//三角参数
with (jiedianlujing_xml[2]) {
var sanjiaoyuanshise = jinzhizhuanhuan(attributes["原始

凌众科技专业提供服务器租用、服务器托管、企业邮局、虚拟主机等服务,公司网站:http://www.lingzhong.cn 为了给广大客户了解更多的技术信息,本技术文章收集来源于网络,凌众科技尊重文章作者的版权,如果有涉及你的版权有必要删除你的文章,请和我们联系。以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢!

分享到: 更多

Copyright ©1999-2011 厦门凌众科技有限公司 厦门优通互联科技开发有限公司 All rights reserved

地址(ADD):厦门软件园二期望海路63号701E(东南融通旁) 邮编(ZIP):361008

电话:0592-5908028 传真:0592-5908039 咨询信箱:web@lingzhong.cn 咨询OICQ:173723134

《中华人民共和国增值电信业务经营许可证》闽B2-20100024  ICP备案:闽ICP备05037997号