5D艺术网首页
商城
|
资讯
|
作品
|
博客
|
教程
|
论坛
登录
注册
加为好友
发短消息
来自:
性别:秘密
最后登录:2007-09-22
http://yuheduo.5d.cn/
首页
|
新闻
|
话题
|
博客
|
相册
|
艺术作品
|
社交关系
|
留言板
|
社交圈
2006/04/28 | Flash虚线函数
类别(Flash学习)
|
评论
(0)
|
阅读(148)
|
发表于 16:44
function dashed(mc, x1, y1, x2, y2) {
var dash = 8;
var ed = 2;
var angle = Math.atan2(y2 - y1, x2 - x1);
var step = dash + ed;
var dashx = dash * Math.cos(angle);
var dashy = dash * Math.sin(angle);
var edx = ed * Math.cos(angle);
var edy = ed * Math.sin(angle);
var stepx = step * Math.cos(angle);
var stepy = step * Math.sin(angle);
var _length = Math.sqrt(Math.pow(x2 - x1, 2) + Math.pow(y2 - y1, 2));
with (mc) {
clear();
lineStyle(0, 0xff0000, 100);
for (var i = step, px = x1, py = y1; i < _length; i += step) {
moveTo(px + edx, py + edy);
lineTo(px + dashx, py + dashy);
px += stepx;
py += stepy;
}
}
}
------------------------------------------
function drawDashedLine(mc:MovieClip, x1:Number, y1:Number, x2:Number, y2:Number) {
var dash = 5 + Math.floor(Math.random() * 5);
var step = dash + 3;
var angle = Math.atan2(y2 - y1, x2 - x1);
var dashx = dash * Math.cos(angle);
var dashy = dash * Math.sin(angle);
var stepx = step * Math.cos(angle);
var stepy = step * Math.sin(angle);
var _length = Math.sqrt(Math.pow(x2 - x1, 2) + Math.pow(y2 - y1, 2));
with (mc) {
lineStyle(0, 0xff0000, 100);
for (var i = step, px = x1, py = y1; i <= _length; i += step) {
moveTo(px, py);
lineTo(px + dashx, py + dashy);
px += stepx;
py += stepy;
}
moveTo(px, py);
lineTo(x2, y2);
}
}
转自:向明空间
0
评论
Comments
日志分类
首页
[149]
blog记事
[7]
Flash学习
[85]
教学记忆
[21]
娱乐影音
[9]
我的收藏
[27]
PhotoShop学习
[0]