Simple Flash mouse Follow-up tutorial

Source: Internet
Author: User
Follow | tutorials | mouse

The mouse following is a flash in the "old" topic, but now there are still people ask this question, we have recently no one on the forum said, I have done six months ago to make a tutorial for everyone to learn, this is entirely my personal production, if there is a similar, purely coincidental.


Mouse Following is actually a very simple problem, can have a lot of algorithms to achieve, here I introduce myself to write a kind of, I hope you reference.

The first step: to create a word MC, there is a dynamic text box in the middle, remove optional, only to be able to hold a word. The color of the word can set itself (must not be and the background is the same AH!) )

Step two: In the library connection to the word MC output as Word symbol has been used in the future you see, the first two-step is easy.
The future is not difficult, as long as you will be a little action

Step Three: (also very easy) in the scene you want to have mobile text (can be the main scene, can also be another MC, I am using a MC called move), the default layer to the action layer, and then add two keyframes, the second frame of the action is:
gotoAndPlay (1);
Note: I do not use MC here, but with two frame of the cycle to replace Entframe, I suggest that you try to write the program in the timeline, because this is more conducive to the management of the program, and procedures to run the order of choice, procedures more at a glance, easy to understand, I hope we develop this good

Fourth Step: (It is not difficult to come here, the following is the key program, is the first frame of the program)
Mouse follow the key is to each text to follow the mouse, but the speed can not be as fast, the last stop position can not be the same, understand this, the program is very easy to understand. The specific procedures and descriptions are as follows:


if (IP = null) {
Mouse.hide (); Hide Mouse
LX = 20; Set the spacing between words
String = "Current frame studio"; Set the text to follow
Wordlenth = String.Length;
For (i=0 i<wordlenth; i++) {
This.attachmovie ("word", "word" +i, i+1);
this["word" +i].word = mbsubstring (String, i+1, 1);
Get the MC and import the word you want to display one at a time
}
ip = 0;
}
//
Delay = 6;//Set delay time to control the speed of Word movement
Word0._x + = (_xmouse+lx-word0._x)/delay;
Initialize the position of the first word
Word0._y + = (_ymouse-word0._y)/delay;
For (I=1 i<wordlenth; i++) {
Determine the move and position of the word later
Delay + 0.5;
this["word" +i]._x + = (this["word" + (i-1)]._x+lx-this["word" +i]._x)/delay;
this["word" +i]._y + = (this["word" + (i-1)]._y-this["word" +i]._y)/delay;
}

The above is the whole procedure, it is so simple, it is not difficult to ^_^.
if (IP = null) The judgment is for the initialization of the data, the program inside is executed only once and will not be executed later.
(This is very useful ah, must be mastered)

The fifth step: Well, all the things are done, the following is the superfluous, is to add a own mouse, to do a mouse of their own mouse into the main scene, and then add a sentence in the action layer:
StartDrag ("Mouse", true);
Also, don't forget to hide your mouse.



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.