Aborigines as Getting Started tutorial object article

Source: Internet
Author: User
Tags expression key words relative
Objects | tutorials | Introductory Tutorials

Although as is not really object-oriented programming, it also has an object concept. This concept runs through the entire as, so the understanding of the object is more important than the grammar or other understanding. Let's start now:

First, let's take a look at the path, which is divided into two types: an absolute path and a relative path. A friend who has done HTML should know the concept. But here I would like to explain in detail, I think the path of understanding to go deep, I am a beginner of the time is to knock on the path.

Before you talk about the path, it is necessary to talk about it first. Grammar: For example, here is a book on a table in a room that says:

Room, table, book

If you want to be more detailed on the page above the words, it is obvious

Room, table, book, page, Word

You see? I don't know how to say that. The syntax is how the object is represented, and the point is preceded by the parent behind it. If the room is the parent of the table, the child of the table is the book. Still don't get it? That's it, you put. In the "Inside" is OK, so that is:

(inside) a table (inside) a book (inside) a page (inside)

It's much easier, isn't it?

Now I began to say the path, which was also to be mingled with the description of the object, to see:

Start with the example. Create a new Flash file and build a MOVIECLIP,MC named "MC", put it in the home scene, then create a button, put it in the "MC", and drag one out of the library to the home scene, naming the two element instances (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 the house, the MC is the table, the button is a book, then how to express the House, table, book? As follows:

_root House

_ROOT.MYMC House. Table

_ROOT.MYMC.MYBTN House, table, book

Here the _root is a flash keyword that represents the Timeline (timeline) of the main scene.

It's easy to understand. The House, the table, the book are the "objects" we want to understand.

When you find this object, you can manipulate the object to apply a method to the object. For example, I now have to clean the house, cleaning is the method, but the object is the house, the expression is this:

House. Cleaning ()

If you can't properly express the object of the house, your cleaning will not be implemented properly.

* Description: Why do you want to add () it behind the sweep? Because cleaning is the method not the object, in order to let Flash know this is a method, we must add (), otherwise it will think that the house has "clean" this thing.

Now, we can easily operate on everything in the room, such as:

House. Cleaning ();

House, wooden table, finishing ();

House, Glass table, broken ();

House, desk, book, Look ();

Wait, I believe you have no problem with translating them into the as code:) For example, to stop playing the main scene, which is

_root.stop ();

To the MC to stop playing, is

_root.mymc.stop ();

Now talk about relative paths. or the example above. If I gave you an order: fix the red chair in the house. So how do you express it? It is:

House. Red Chair. Repair ();

No matter where the person who gave you the order told you, you would know which chair to repair. But if he says so: Fix the chair you're sitting on. The red ones? Or the blue one? It depends on which chair you are sitting on. So the relative expression is.

I sit in the chair. Repair ();

Why don't you write this here:

The house. I sit in the chair. Repair ();

This is wrong, because I sit in a chair is not fixed, I might move a chair outside the house to sit, then this expression is wrong, because the chair is not in the house.

In exchange for the Flash instance description. Now I want to let the MYMC in the main scene not play at the beginning, but stop first. So what can you do?

I guess the idea is to put it in the frame of the MC at the home scene:

_root.mymc.stop ();

That's the right one. But once MYMC's name changes, you have to change the sentence.

There is no way regardless of the "MC" instance name, regardless of how to change, will be our same sentence as found? Of course, if your as must "sit on this MC".

Into the MC of the editing state, in the MC Timeline the first frame written.

This.stop ();

This is also the keyword for flash, this is the Timeline of the AS.

Now no matter where you put the MC, the name is what, I do not care, anyway, will certainly stop. Why, because as is "sitting on the MC".

This.stop ();

If you write in here.

That's a mistake. Why? Think about it carefully.

This is one of the key words for the relative path. You have to understand it carefully.

Another key word is _parent. If you understand this, then _parent is not difficult to understand. Example:

or which Assumption House (_root), table (Mc_zhuozi), book (Mc_shu) Their relationship is (in parentheses for the MC instance name)

The House, the table, the book

_root.mc_zhuozi.mc_shu

In the timeline of Mc_zhuozi, write:

_parent. cleaning ();

It means cleaning the room.

In the timeline of Mc_shu, write:

_parent. cleaning ();

It means cleaning the table.

_parent is also the parent level. The _parent of the table is the timeline of the house, the _parent of the book is the timeline of the table. The _parent of the object behind the point is the object in front of the point.

This is the right time to review:

Point Grammar learns to express objects.

Learn to express objects with absolute and relative paths.



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.