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