Course Objectives:
1, Learn to make video clips
2, the Institute named to the example
3, learn the syntax of dynamic named 3460
4, learn the syntax of the function replication
5, can do a simple copy function, the effect of
First, the function Introduction
How to use the vending machines? You go into a vending machine or in a few coins, it will spit out a coke or something.
We take a look at the work of sales, input - output deal ---- that is, able to enter anything as long as we know it can output anything on the line, without having to know how sales work.
Function like a vending machine, we do not want to know how to write a function, just to know how to enter things into a function, enter the following function to get to know what the results.
Vending machine is selling goods, the function is a certain function, such as copy function to copy video clips, take a look at written copy functions:
duplicateMovIEClip ()
/ / Function name ()
The function name we have to remember the simplicity of it, because in FlashMX2004, there is no normal mode, only the expert mode, that is, you can manually input function (typing slow comrades to practice my typing).
The operation of vending machines has its own rules, the same function, you must enter the correct format, grammar, as follows:
duplicateMovieClip ("Old instance name" and "new instance name", "depth")
Syntax from the copy function can be seen in the copy function we must enter three "coin", the "coin" in Flash, called parameters, so we have to enter in the replication function of three parameters. The output result is: the flash was the only one in the movie clip, copy the function call, there are two video clips, we can name the movie clip instance to operate on them.
Second, the copy of a movie clip
1, first create a movie clip instance named mc1.
2, in an action panel, enter the following code:
duplicateMovieClip ("mc1", "mc2", "1")
3, Test Movie
Can see that does not seem to replicate to another movie clip, because the copy out and mc1 mc2 is exactly the same, including their location coordinates that are the same, they overlap together.
We exit the test mode, open the Actions panel, add another line of code:
mc2._x = 300
Test movie, is not to see a movie clip mc2.
Third, copy the two video clips
We modify the example code:
duplicateMovieClip ("mc1", "mc2", "1")
mc2._x = 300
duplicateMovieClip ("mc1", "mc3", "2")
mc3._x = 400
Test the movie viewing, the scene should have three movie clips
In particular, note that the depth of the two replication must be different, otherwise the movie clip with the depth of coverage will be opened before one can attempt to do so, the code read:
duplicateMovieClip ("mc1", "mc2", "1")
mc2._x = 300
duplicateMovieClip ("mc1", "mc3", "1")
mc3._x = 400
Re-testing, is not it only two? That is, only a copy of which was mc2 mc3 covered.
Fourth, copying multiple movie clip
If we want to copy the 10 video clips, is not to write 10 copy function?
No, we take a look at how to achieve dynamic instance name?
If there is to copy the instance name mc2, mc3 ... .. mc11 movie clips, we can dynamically name the following syntax:
"Mc" i
Where i is variable from 2,3 ... .11
Because i have a range of variables, so we use the loop to the example code to read:
for (var i = 2; i <= 11; i) {
duplicateMovieClip ("mc1", "mc" i, i)
this ["mc" i]. _x = 10 * I
}
To test to see results
Attention to two issues:
1, the depth is not the same, I use the variable i, so definitely not the same
2, the reference dynamic instance name, to add the path, this indicates that the current path, the syntax is as follows:
Path ["mc" i]
There is no middle point, it should also pay attention
Assignment:
Copy function to do with an effect, such as the physical effects of the strobe
Note: If you flash is not very familiar with the basic operations, such as do not know how to open the Actions panel, do not know how to name the instance, let us work together to supplement this tutorial, you will what to add anything, to do our tutorial perfect as possible.
没有评论:
发表评论