Flash website Common Effect analysis

Source: Internet
Author: User
Tags goto
Effects

Flash Web site with its ingenious ideas, colorful for most avantgarde designers prefer. It brings the visual, the impact of sound effects, compared with the design of traditional Web pages, has a huge appeal. In view of the speed of the problem, we need to consider the production of loading to improve the flash site. What if there are a lot of external wsf files that need to be loaded into the main SWF file? Today, we will discuss similar foreign famous site 2advancwww.2advanced.com) The method of preparing the page in advance. (Specific effect to visit the site to observe)
First to learn the general loading of the production of ideas. It is implemented using ActionScript. A new layer, this layer is dedicated to action,
First frame,
ifframeloaded ("Scene", frame) {//If the number of frames in the scene has been loaded
Goto and Play ("Start")//jumps to and plays So-and-SO (the frame label you set)
}
Second frame,
Goto and Play ("Scene 1", 1)//jumps to and plays the first loop
Plus a load MC loop playing in the middle of these two frames, OK. Many beginners are puzzled by the positioning of the external SWF in the main SWF for the Loadmovie call. In fact it's very simple, if it's loadmovienum in, add as:this._x=100;this._y=200 to the first frame of the calling external SWF file (this is the coordinates you want the external SWF to be in the main SWF scenario) If the Loadmovie statement calls SWF to an empty MC, just put the empty MC in the upper-left corner of the location where you want the external SWF to be located, such as coordinates (100,200).
If you want to achieve accurate download, Flash 5 has a wonderful function: getbytesloaded () and Getbytestotal (). Where: getbytesloaded () lets us get the number of bytes that have been downloaded, while Getbytestotal () tells us how many bytes there are in the file. We're at home. A dynamic text setting variable is the instance name of a rectangular strip with a length of 100, and then the bar length is changed to 1 on the stage Input,bar. Add as on the first frame:
_root.onload = function () {
TotalBytes = _root.getbytestotal ();
}
_root.onenterframe = function () {
Loadedbytes = _root.getbytesloaded ();
PercentDone = Int ((loadedbytes/totalbytes) *100);
Show download progress to number%
Output = percentdone+ "% of file loaded";
The X dimension of the progress bar is the download progress PercentDone
_root.bar._xscale=percentdone;
If load is complete
if (percentdone >= 100) {
Goto Frame 2
This.gotoandstop (2);
Terminate this loop
_root.onenterframe = null;
}
};
The general logical way to see the following figure:


Well, through the above two kinds of loading, I believe you have been familiar with the loading steps. We started the formal preload production.
First: Create a new movie. The size is 550x400 and the color is black. Use the rectangular tool to draw a rectangle with a long width, respectively, 54,18. Press Ctrl+f8 to change to a button. To beautify, you can build a key frame by pressing F6 in the rollover area and turn the color of the rectangle into red.
Second: Pull the button we just made from the library to the editing area. Pull out 3 (this is the benefit of making components, you can reuse them) and arrange them horizontally. To create a new layer, select the type tool to write separately in the middle of each button:
Button 1,button 2,button 3, the font color is black.
Third: In the editing area, draw a rectangle with no fill, a blue border, open the property panel, the length, the width of the value entered 550,184. Coordinates 0,180, press ENTER to determine. Press Ctrl+f8 to turn it into a movie clip, with the instance name as content. The same method creates a new component named control, creates a blank keyframe in the second frame, draws a white rectangle in the editing area, has a width of 0.5, and coordinates (0,0). Press F6 to build keyframes on frame 40th. Build the keyframe on frame 20th and set the rectangle width to 550,184. Its coordinates are ( -275,-92). OK, right-click between 1 and 20 frames, 20 and 40 frames, and select the first option (Create motion Tween) to animate. Create a new layer, add a blank keyframe at 20 frames, draw a rectangle, and turn it into a movie clip (instance named Loadbar). Build a new layer,
In the first frame add the statement: Stop (), in 20 frame plus statement: Stop ();
Load the SWF file we need (later made)
Loadmovie (_root.nextmovie,_root.content); Load the NextMovie swf file into the content MC.
Select 2, 21 frames, and name the frame in the Properties panel (term frame label). 2 frames are "close" and 21 frames are "open". Build another layer and add a movie clip to the 20 frame Loadbar. As described above, it is an instance name of a rectangular strip, with a length of 100, and then on the stage the Loadbar length becomes 1. The film clips are done.
Four: Back to the main scene. Take the 3 buttons we made to start the instance named Bt1,bt2,bt3. Then drag the control component from the library to the scene, starting with the instance named cover, coordinates (275,200) (Note that our control element is empty for the first frame, so there is only a small circle in the scene.) Veteran are impatient to see, oh, in order to take care of beginners, I am wordy, is not a cheat fee oh. Now take a look at your editing area, like the following diagram:

Five: Create a new layer and write code on the first frame:
Stop ();
But1.onrelease=function () {
Set a variable to store the name of the SWF file we want to load
Nextmovie= "content1.swf";
Tell over MC to play close animation.
Cover.gotoandplay ("Close";
}
But2.onrelease=function () {
Nextmovie= "content2.swf";
Cover.gotoandplay ("Close";
}
But3.onrelease=function () {
Nextmovie= "content3.swf";
Cover.gotoandplay ("Close";
}
Sixth: The main SWF file is completed, and we continue to make the SWF that we want to load. Here, for the sake of simplicity, we do only two frames. The movie size is 550x184 and the content is as large. The first frame plus code (I believe everyone is not unfamiliar)
This.onenterframe = function () {
Check if load is complete this refers to the object being invoked.
if (this.getbytesloaded () <this.getbytestotal ()) {
Total = This.getbytestotal ()/1000;
Received = this.getbytesloaded ()/1000;
Percentage = (received/total) *100;
Start progress bar Animation
_root.cover.loadbar._scale= percentage;
} else {
When fully loaded
gotoAndStop (2);
Tell over MC to play open animation.
_root.cover.gotoandplay ("open";
Cancel Enterframe Action
This.onenterframe = null;
}
};
Stop ();
The second frame I did a random MC, everyone in practice can do their favorite animation. Just for the purposes of the test, we do a total of 3 SWF, and the filename is content1,content2,content3. Needs to be saved under the same file as the main SWF file



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.