Flash Animation | follow | follow mouse | spider
The previous personal network of a dot, with the line to achieve, hoping to give an imaginative comrade a little inspiration.
The finished effect is as follows, we move the mouse, you can see the spider silk will follow the mouse to move and stretch.
Here's how to implement it,
(1) first built three MC, as follows:
One is SPIDER_MC, draw a spider, a decent point to forget, hehe! One is NET_MC a net, when the background is used, no use! The last one is an empty MC, called LINE_MC, to draw the line.
(2) Back to the scene, build three layers as follows:
The bottom of a call net, used to put background net, pull net into; the middle of a layer called line, used to put LINE_MC, LINE_MC pull in, and give this clip named LINE_MC; the last one of course is put spider_mc, a little nonsense!
(3) OK, the final key step, build an action layer, write the following code:
speed=10;
Spider_mc.onenterframe = function () {
DX = _root._xmouse-this._x;
dy = _root._ymouse-this._y;
P =math.atan (DY/DX) *180/math.pi;
Rota = (dx>0)? (90+p):(270+p);
This._x + = Dx/speed;
This._rotation = Rota;
This._y + + dy/speed;};
Line_mc.onenterframe = function () {
This.clear ();
This.moveto (0, 0);
This.linestyle (1, 0XFFFFFF, 100);
This.lineto (_root.spider_mc._x, _root.spider_mc._y);
}; End