Interactive Flash Animation: Follow the mouse to move stretched spider silk

Source: Internet
Author: User
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.