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。
本文到此結束,希望對大家有所幫助。

相關文章
精彩導讀
熱門資訊