Flash as learning: learn as from scratch

Source: Internet
Author: User
Tags copy insert visibility

1th Case Movie Property Control

First look at the example:

[Example Description] This example shows how to implement control of movie properties. such as transparency, scaling ratio, quality, visibility and so on.

[Knowledge Point]

On (mouse event): Performs an action when a mouse event occurs. Mouse events Common options: Release the mouse when the mouse pointer passes over the button, press the mouse while the mouse pointer passes over the button, and the Rollovert mouse pointer moves the f button.
SetProperty (movie clip name, property option, property value): Sets the movie clip properties.
GetProperty (Movie clip. _ Property): Returns the properties of the movie clip;

if (condition) {Program 1} condition is True, execute program 1,
else{Program 2} otherwise execute program 2.

This example property: _alpha (transparency) _width (width), _height (height), _visible (visibility), _highquality (quality, 2 for high quality, 0 for low quality)

Operator:

1,! Logical non-operator. W=!w:w true (True) when the value of!w is not true (false) (false), and W is False (false),!w value is not false (true) (true).

2, = = comparison operator. Compare the values on both sides of the "= =" match.

[Production example]

1, the establishment of documents.

2, according to CTRL+8 combination of a new movie Clip (film clips), named Lady. Casually put in a picture.

3. Press Ctrl+8 to create a new five button (button), make "-", "+", "High quality", "Low quality", "visibility" button.

4, in the home scene, the panel's five buttons are dragged to the Layer 1 layer, and copy the "+" and "-" button each one, as the zoom and shrink button, the scene layout as shown:

5, and then create a new layer, the Library of the Lady movie clip into the LAYER2 layer of the appropriate position, and named Mov.

6, in the increase Transparency button point right click, select the action, add the following as code.

On (release) {
Increase _alpha value
SetProperty ("mov", _alpha,getproperty (Mov,_alpha) +5);
if (mov._alpha>=100) {
SetProperty ("mov", _alpha,100);
}
}

7, in reducing the transparency button on the right click, select the action, add the following as code:

On (release) {
Reduce _alpha value
SetProperty ("mov", _alpha,getproperty (Mov,_alpha)-5);
if (mov._alpha<=0) {
SetProperty ("mov", _alpha,0);
}
}

8, with the above method in the Amplification button to add as code:

On (release) {
Enlarge the width and height of a movie clip
SetProperty ("mov", _width,getproperty (mov,_width) +5);
SetProperty ("mov", _height,getproperty (mov,_height) +5);
}

9, add the as Code on the Zoom button:

On (release) {
Reduce the width and height of movie clips
SetProperty ("mov", _width,getproperty (Mov,_width)-5);
SetProperty ("mov", _height,getproperty (Mov,_height)-5);
}

10, add the as code on the visibility button:

On (release) {
W=!w;
if (w==true)
{
Set Movie as Visible
SetProperty ("mov", _visible,true);}
Else
Set Movie not visible
{setproperty ("mov", _visible,false);}
}

11, on the High quality button to add as code:

On (release) {
Set up a movie for high quality
SetProperty ("mov", _highquality,2);
}

12, on the Low quality button to add as code:

On (release) {
Set the movie as Low quality
SetProperty ("mov", _highquality,0);
}

Demonstrate

[Knowledge Point]

1. Copy Movie clips:

Duplicatemovieclip ("copied movie", the name of the new movie object, the level of the object in the scene);

2, set the movie properties: SetProperty (film name, attributes, values);

3, produce random number: random (numerical range)

4, jump to a specific frame and play: gotoAndPlay ("frame tag or frame number");

[Production example]:

1, create a new file, press Ctrl+f8 key to create a new MC movie clips, and named Drop. Make a short white line in frame 1th of layer 1th, insert keyframes at frame 20th, and adjust the white line position, set 1 and 20 frame motion gradient, make the effect of rain fall; draw a white unfilled ellipse in frame 21st, insert keyframes in frame 35th, enlarge the ellipse, and note that the circle in the 21st frame is concentric. Set the gradient between 21 frames and 35 frames to make the white oval expand. Insert a blank keyframe in frame 36th, press F9 to eject the action panel, and enter the as code "

Stop ();

2, back to the main scene, press Ctrl+l to bring up the library panel, the film drop into the first frame, the life instance named drop (in the lower left of the property panel x, y above, can not refer to the first example of the picture), in the second frame insert frame. And then create a new layer, in the 1th frame press F9 to pull up the action board, enter the following code:

Copy Drop movie Clips
Duplicatemovieclip ("_root.drop", c,c);
Set the copied movie clip coordinates
SetProperty (C,_x,random (550));
SetProperty (c,_y,0);

3, in the second layer, the second frame of the right mouse button, converted to a keyframe, enter the following code:

Cumulative number of copies
c=c+1;
Jump to frame 1th
gotoAndPlay (1);

As shown in figure:

OK, you can press CTRL + ENTER to demonstrate.

Note: The red part of your code is a comment, and you don't need to enter it. In as, a comment that begins with "//" is a note, and the program does not execute. Can be either a single line or after each line of code.



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.