AS object articles
-----------------------------------
Here is the two connections, haven't seen it? Go and see it.
Getting Started Tutorial in Tuner Series - Basic Articles
Tuner AS Getting Started Tutorial - Grammar
Although AS is not a true object-oriented programming, it also has the concept of objects. This concept is always through the entire AS, so the understanding of the object is more important than grammar or other understandings. Go now:
First, let's take a look at the path, the path is divided into two types:
Absolute path and relative path. Friends who have done html should know this concept. But here I still have to explain in detail, I think it is going deep into the path, I am going to the path when I start school.
Before the path, it is necessary to talk about. Syntax: For example, here is a book on the table in the room, use. Syntax said:
Room. Table. Book
If you want to fine to the words on the page on the book, it is obviously
The room. Table. Book. Page. Word
Look, is it? I don't know how to say,. The syntax is to indicate that the object is, the front of the point is the parent thereof. If the room is the parent of the table, the child's child is a book.
Still do not understand? This way, you will be "inside", this is
Room (inside) Table (inside) book (inside) page (inside) word
This is much easier?
Now I start to say the path, which is also a description of the object, see:
Start with example. Create a flash file, then create a movick, MC named "MC", put it in the main scene, then create a button, put it in "MC", then drag it from the library, give it out, give it out, give These two elements instance named (INSTANCE NAME, note that the instance name is not the name of the MC): mc-> mymc button-> mybtn
Now we assume that the main scene is a house, MC is a table, buttons are books, so how to express houses, tables, books? as follows
_root house _Root.mymc house. Table _Root.mymc.mybtn house. Table. book
Here _root is the keyword of Flash, indicating Timeline of the main scene.
It is easy to understand right. The houses, tables, books here are "objects" we have to understand.
When you find this object, you can do ways to operate the object. For example, I have to clean the house now, clean it, but the object is a house, the expression is like this:
House. Cleaning ()
If you can't express this object correctly, your cleaning will not be implemented correctly.
* Description: Why is this after the cleaning ()? Because the cleaning method is not an object, in order to let Flash know this is a method, we must add (), or it will think that there is "cleaning" in the house.
Now, we can easily operate everything in the room, such as
House. Cleaning (); house. Wooden table. Corruption (); house. Glass table. Broken (); house. Desk. Book. See ();
Wait, I believe that you have no problem with "translation" as an AS code :) For example, you have to stop playing with the home scene,
_root.stop ();
To stop playing with MC,
_Root.mymc.stop ();
Now talk about relative paths. Still the above example. If you give you a command: repair the red chair inside the house. So how do you express it? Is:
House. Red chair. Repair ()
No matter where the people undergoing the order tell you, you will know which one to be repaired. But if he said: Repair you are sitting now. Red? Still blue? This will depend on which chair you are sitting. Then the relative expression is the chair I sit. Repair ();
Why don't you write this here: House. I am sitting chair. Repair ()
This is wrong, because I am sitting in the chair, I may not be able to move the chair to the outside, then this expression is wrong, because the chair is not in the house at all.
In exchange, use the Flash example. Now I want to play my MYMC in the home scene, don't play at the beginning, but stop first. So what do you have?
I guess the way I may put into the frame of this MC in the main scene:
_Root.mymc.stop ();
This is right. But once the name of mymc changes, you have to change this sentence.
Is there a way to change this "MC" instance name, will we be found by the same AS? Of course, the premise is that your AS must "sit on this MC".
Enter the Edit state of the MC, write on the first frame of the MC Timeline
THIS.STOP ();
here
This is also a keyword of Flash, this this THIS refers to this timeline.
No matter where you put this MC, what is named, I don't have, anyway, will definitely stop. Why, because AS is "sitting on MC".
If you write _root.stop (); then it is wrong. why? think carefully.
This THIS is one of the keywords of the relative path. You have to understand it carefully.
Another keyword is
_parent. If you understand this, then _parent is not difficult to understand. Example:
Stat to a house (_root), table (mc_zhuozi), book (mc_shu) their relationship is (MC instance name in parentheses)
House. Table. Book
_Root.mc_zhuozi.mc_shu
Write in the Timeline of MC_Zhuozi
Cleaning ();
It means cleaning the room;
Write in the Timeline of MC_SHU
Cleaning ();
It means cleaning the table.
_Parent is also a parent. The _parent is the Timeline of the house, the _parent is also the Timeline of the table. The _parent is the object of the back of the point.
This is here, review:
Prosecution
Learn to express objects
Learn to use absolute path and relative path
If you understand, then we can enter the actual combat. Drink water .. (To be continued)