作者Jedic (真诚的勇者)
看板Flash
标题Re: [问题]我是个新手,想问这个怎麽做
时间Fri Dec 10 11:50:36 2004
※ 引述《jacket (小胖胖!!)》之铭言:
: 我想做一个flash是一开始出现两个点座标
: 然後之後就从一个点延伸出一条线连到另外一个点
: 就这麽简单,但是因为我之前没碰过flash所以不知道从何下手
仅就第一小题作提示
先作一个library物件,只是一条水平线段,长短不限
但左端点必须对齐座标(0,0)
不要有粗细的设定值,不然会越来越粗,linkage name取为theline
frame1 actionscript:
//两点座标,稍後可改成由文字栏输入
posX1 = 0;
posY1 = 0;
posX2 = 300;
posY2 = 400;
//求得对X轴夹角,单位是弧度
radians = Math.atan2(posY2-posY1, posX2-posX1);
//换算成可用的度数
degree = (radians/Math.PI)*180;
//线段每次的延伸量
extend = 5;
//用来指定线段物件的长宽变量
xExtend = extend*Math.cos(radians);
yExtend = extend*Math.sin(radians);
//纪录上一次的线段物件长宽
var lineWidth = 0;
var lineHeight = 0;
//描线函式
function drawline() {
attachMovie("theline", "theline", 1);
theline._x = posX1;
theline._y = posY1;
theline._rotation = degree;
theline._width = lineWidth+xExtend;
theline._height = lineHeight+yExtend;
lineWidth = theline._width;
lineHeight = theline._height;
//
if (theline._width>=Math.abs(posX2-posX1)) {
theline._width = Math.abs(posX2-posX1);
theline._height = Math.abs(posY2-posY1);
clearInterval(drawInterval);
}
}
//
drawInterval = setInterval(drawline, 25);
: (ps:这个问题是我机动学老师派给我们做的
: 他要自己找一个程式可以输入点座标然後画出四连杆的模样
: 最终目标是要让他一根杆旋转带动其他根的动作情形要弄成动画
: 而现在最简单的步骤就是要先弄出一条线来,这样才能接续到後面
: 不过我刚刚稍微摸了一下,我不太清楚时间轴要怎麽弄,找不到选项让他跑QQ
: 然後怎麽做出一条线慢慢延伸的动画我也弄不出来,只能直接跑出一条线)
--
═╬═╬═ ╔═╗ ═ ╭╬╮╯═╤╤═
╭═╬═╮╔═╗╠═╣═╦═╠╬╣ ╬╬╬╬
║ ║ ║╠═╣╠═╣║║║║║║═╩╩╩╩═
╩╦╩╦╩╚═╝║ ║║║║╰╬╯ ╭╦ ╔╬
╭╯ ╰╮ ╯ ╝ ║ ║ ╩╯ ╩╬
※ 编辑: Jedic 来自: 61.66.87.212 (12/10 11:53)