用纯AS写滚动条
2008-04-02 11:04:53来源:互联网 阅读 ()
前两个星期抽时间看了看一直很感兴趣却没时间研究的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["原始色"]);
var sanjiaohuodongse = jinzhizhuanhuan(attributes["活动色"]);
//记录下原始色和活动色,以备在“上”,“下”按钮中使用
jiluyuanshise = attributes["原始色"];
jiluhuodongse = attributes["活动色"];
var sanjiaotoumingdou = attributes["透明度"];
}
//滑块参数
with (jiedianlujing_xml[3]) {
var huakuaibeijingse = jinzhizhuanhuan(attributes["背景色"]);
var huakuaitoumingdu = attributes["背景透明度"];
var huakuaibiankuangse = jinzhizhuanhuan(attributes["边框色"]);
var huakuaibiankuangtoumingdou = attributes["边框透明度"];
var huakuaibiankuangcuxi = attributes["边框粗细"];
}
//先根据文本域的高确定滚动条的高
gundongtiaogao = wenben_txt._height;
标签:
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有
上一篇: 关于倒计时程式的准确性解决方法
下一篇: Flash制作发散的彩球教程
IDC资讯: 主机资讯 注册资讯 托管资讯 vps资讯 网站建设
网站运营: 建站经验 策划盈利 搜索优化 网站推广 免费资源
网络编程: Asp.Net编程 Asp编程 Php编程 Xml编程 Access Mssql Mysql 其它
服务器技术: Web服务器 Ftp服务器 Mail服务器 Dns服务器 安全防护
软件技巧: 其它软件 Word Excel Powerpoint Ghost Vista QQ空间 QQ FlashGet 迅雷
网页制作: FrontPages Dreamweaver Javascript css photoshop fireworks Flash