Flash mx Practical Programming hundred examples to interpret a

Source: Internet
Author: User
Tags visibility
Programming a few days ago on the internet under the "Flash MX practical Programming Hundred cases", open the source code looked at, the total feeling of the example is OK, but the code is too old, some or Flash 4 format, and then want to adapt the code, one is a learning, two will take the opportunity to have their own knowledge to comb.

a few examples of Flash practical programming ----transparency magnifies and reduces high quality and low quality visibility

Steps

1. Open Flash MX 2004, create a new document, set the document size to 300*300 pixels
2. Create a New button, drag the button to the stage, copy 6 copies, create 7 button instances, and arrange them.
3. Use the type tool and the line tool to write or draw the corresponding symbol on these buttons.
4. Import or create the objects you need to observe, either a picture (vector or bitmap) or a video, but should be placed in a movie clip, where the ladybug (ladybug) vector is used as an object of observation, with an instance named Ladybug.
5. Select the transparency Increase button, press F9 to open the Action Script editing window, enter the following code:
On (release) {
This.ladybug._alpha + 5;
if (this.ladybug._alpha>=100) {
This.ladybug._alpha = 100;
}
}

6. Back to the main scene, select the Transparency reduction button, press F9 to open the Action Script editing window, and enter the following code:
on (release) {
This.ladybug._alpha = 5;
if (this.ladybug._alpha<=0) {
This.ladybug._alpha = 0;
}
}
7. Back to the main scene, select the Zoom button, press F9 to open the Action Script editing window, and enter the following code:
on (release) {
This.ladybug._xscale + + 5;
This.ladybug._yscale + 5;
}
8. Back to the main scene, select the Zoom button, press F9 to open the Action Script editing window and enter the following code:
on (release) {
This.ladybug._xscale-= 5;
This.ladybug._yscale-= 5;
}
9. Back to the main scene, select the High quality button, press F9 to open the Action Script editing window, enter the following code:
on (release) {
this.ladybug._highquality=2;
}
10. Back to the main scene, select the Low quality button, press F9 to open the Action Script editing window, enter the following code:
on (release) {
this.ladybug._highquality=0;
}

The settings for visibility are slightly more complex, with the following steps:
11. Back to the main scene, select the Visibility button, press F8 to convert it to a movie clip (in essence, include the visibility button in this movie clip), select the movie clip, press F9 to open the Action Script editing window, and enter the following code:
Onclipevent (load) {
W = true;
}
Note: Set a variable w record this button click state, W is actually the movie clip inside the timeline variable, can not be declared with the Var syntax, or become a local variable.
12. Return to the main scene, double-click the visible movie clip, enter the movie clip, select the visibility button, press F9 to open the Action Script editing window, and enter the following code:
On (release) {
W=!w;
if (w==true) {
_parent.ladybug._visible=true;
}else{
_parent.ladybug._visible=false;
}
}
So far, all work is done.

A few impressions:
1. Use this and _parent as much as possible in programming, and use less _root to ensure the portability of the program.

2. The variable in the script on the button is the timeline variable of the movie clip that contains the button, and the variable in the script on the movie clip is the timeline variable within the movie clip.


The effect is as follows:

http://www.flash8.net/bbs/UploadFile/2005-6/200561205277.swf



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.