1、当你移动鼠标时,你可以看到蜘蛛丝会随着鼠标移动和拉伸。
2、先说实现方法。
3、首先在闪存中构建三个MCs。
(资料图片仅供参考)
4、一个是spider_mc,画个蜘蛛,体面点就行,呵呵!
5、一个是net_mc,一个蜘蛛网,作为背景使用,但是用处不大。
6、最后一个是空MC,line_mc,用来画线(蜘蛛丝)。
7、回到场景,建立三层。
8、最下面的叫网,用来放背景网,拉进来。
9、中间层叫line,用来放line_mc。拉入line_mc,并将此剪辑命名为line_mc。
10、最后一个当然是spider_mc。
11、最关键的一步是建立一个动作层,并编写下面的代码。
12、复制代码
13、代码如下:
14、speed=10;
15、spider_mc.onEnterFrame=function() {
16、dx=_root._xmouse-this._x;
17、dy=_root._ymouse-this._y;
18、p=Math.atan(dy/dx)*180/Math.PI;
19、rota=(dx0) ? (90+p):(270+p);
20、this._x +=dx/speed;
21、this._rotation=rota;
22、this._y +=dy/speed;
23、};
24、line_mc.onEnterFrame=function() {
25、this.clear();
26、this.moveTo(0,0);
27、this.lineStyle(1,0xffffff,100);
28、this.lineTo(_root.spider_mc ._x,_root.spider_mc ._ y);
29、};
30、最后,生成并完成swf。
本文到此结束,希望对大家有所帮助。