Flash ActionScript Learning: Write as on the MC

Source: Internet
Author: User

Demo Effect:

Click here to download the source file

First of all, it should be clear that the current recognition of the film clips (MovieClip) of the call MC, how to create an MC? Follow one of the following methods:

1, press the CTRL+F8
2, select the Insert in the menu | | New symbol
3, on the stage to draw a graphic, right click | | Convert to Component | | Select a movie clip in the behavior
4, import a bitmap, right click | | Convert to Component | | Select movie clips in behavior, etc...

Now we've drawn a movie clip. Select the movie clip, open the Action panel, and enter the statement in the action panel. Please see what I'm going to respond to when I enter these statements now.

The above effect is: when the mouse clicks on the worm, the worm's x coordinates move 100 pixels to the right, this is the object that is being clicked the bug MC _x is the property of the movie clip, the X coordinate value, + = is the equivalent this._x=this._x+100 assume the original worm's x-coordinate is 200, Then add 100, that's 300, and the bugs move like 100 on the right.

As you can see from the example above, the reader may ask: is the handle written on the movie clip the same as the handle written on the MC? The answer is: not exactly right, all the buttons can use the handle, movie clips can also be used, but the movie clip can use the handle, the button is not necessarily available.

Now we're going to put this segment as on the bug above.

Onclipevent (load) {
This._width=62.5*2
This._height=47.5*2
}

After the test, we can find that the worm's long width is twice times the original. The onclipevent (load) Here is a handle to the event of a movie clip, and you know what events you can have, see this figure

Click Onclipevent, a look at the action panel can know that the proposed load Enterframe the two most common familiar, load is a movie clip load after the event, such as the previous example, the movie clip loaded after the length of their own to become twice times the original Enterframe is an event that is continuously executed after the movie clip is loaded.

Please write this statement on the worm for testing.

Onclipevent (enterframe) {
this._x+=2
}

The movie clip event can also be written on a hardwood. You can do that by writing the statement on the right of the bug that just controlled it.
1, select Bugs, open the Properties panel, enter the MC instance name: Bug
2, select the first frame, open the action panel input

Bug.onenterframe=function () {
this._x+=2
}

This statement is exactly the same as the preceding paragraph.

  Practice advice:

Be familiar with the meaning of events in some movie clips. Learn some of the methods and properties of MC.



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.