To invoke the SWF file correctly in the Flash courseware

Source: Internet
Author: User
Tags transparent color rewind

As we all know, SWF file is one of the standard file formats of flash output, it is widely used in Powerpiont, Authorware and other software can be easily invoked. So how do you use SWF files in Flash? This article will give you a detailed description of the relevant technology.

When you use Flash to make courseware, you often need to use some out-of-the-box SWF files, using the Import command in Flash to use SWF file, will completely destroy the original file structure. In addition, for large courseware, we can group cooperation, and then by invoking the SWF to combine the courseware, this can reduce the volume of the main document of the courseware, but also facilitate the overall cooperation in the production of large courseware.

The invocation and control of SWF file

Let's learn how to invoke and control SWF files by introducing the courseware "only one Earth" (shown in the picture). In the figure, the gray portion is 340x300 (pixel), which is the part of the SWF file playing area. The right side is a text button (for example: Fragment one, fragment two ...). , which is the call button for the SWF file, below is the control button for the SWF file, and can be implemented from left to right: play, pause, rewind, fast-forward, go back to the beginning, skip to the end, increase the volume and decrease the volume. In the courseware storage directory has 6 SWF files, they are called files, the name is: Fragment one, fragment two, fragment three ... The scene sizes of these files are as large as the gray ones, 340x300 (pixels), and a title animation named: Title animation. swf.

Step 1th starts Flash Mx 2004, draws the interface using the tools in the drawing toolbox, and adds some text. Press "Ctrl+f8" to create the button you want, and then drag and drop it to the appropriate location in the interface. Press "Ctrl+f8" to create a movie named "SWF" (MovieClip) with no settings in it, and then press "Ctrl+l" to open the library, drag the SWF movie to the scene, and match its center point to the upper-left corner of the gray area, and then click ( Properties) (property) button, set its "Instance Name" to "SWF", and finally save the file to a folder (note: The called SWF will also be placed in this folder, otherwise it cannot be invoked, if the original SWF file has a background color set, is automatically stripped of the transparent color when called.

Step 2nd adds the following actions statement for frame 1th of the scene:

Fscommand ("fullscreen", true);

Set up the courseware to play in full screen.

Fscommand ("Allowscale", false);

When the courseware window size changes, the content in the courseware maintains the original size.

Loadmovie ("title animation. SwF", "SWF");

Invoke the title animation into the movie SwF.

Movie_sound = new sound (SWF);

Bundles the sound files in the movie SWF.

Movie_sound.setvolume (50);

Sets the volume of music in the movie SwF to 50, and the highest is 100.

Yinliang = Movie_sound.getvolume ();

Set the variable Yinliang so that its value is equal to the volume of the movie SWF.

The 3rd step adds the actions statement to the text button on the right side of the scene, and the statement of the fragment one button is as follows:

On (release) {

Unloadmovie ("SwF");

Clears the original contents of the SWF movie.

Loadmovie ("Fragment one. swf", "SWF");

Call fragment one file to the SWF movie.

}

The statement for the "Fragment Two" button is as follows:

On (release) {

Unloadmovie ("SwF");

Loadmovie ("Fragment two swf", "SWF");

}

The rest of the text button's statements are similar to the above, just change the name of the calling file.

Step 4th below to set the actions statement for the control button:

Play button:

On (release) {

Root.swf.play ();

}//When you click the button, the SWF movie plays in the current scene.

Pause button:

On (release) {

_root.swf.stop ();

}//When you click the button, the SWF movie in the current scene is paused.

"Rewind" button:

On (release) {

if (_root.swf._currentframe>=40) {

_root.swf.gotoandstop (_ROOT.SWF._CURRENTFRAME-40);

When the button is clicked, if the current frame is greater than or equal to 40 o'clock, the SWF movie in the scene subtracts 40 frames from the current frame to achieve a fallback, where 40 can be set according to the situation.

} else {

_root.swf.gotoandstop (1);

Otherwise the SWF movie jumps to frame 1th.

}

}

Fast Forward button:

On (release) {

_root.swf.gotoandstop (_ROOT.SWF._CURRENTFRAME+40);

}//Click this button, and the SWF movie adds 40 frames from the current frame, which enables fast forward.

"Back To start" button:

On (release) {

_root.swf.gotoandstop (1);

}

Skip to End button:

On (release) {

Dangqianzhen = _root.swf._totalframes;

The value that sets the variable dangqianzhen equals the total number of frames in the SWF movie, the last frame.

Root.swf.gotoAndStop (Dangqianzhen);

Let the SWF movie jump to the last frame.

}

Increase Volume button:

On (release) {

if (_root.yinliang<=90) {

_root.yinliang = _root.yinliang+10;

_root.movie_sound.setvolume (_root.yinliang);

If the current volume value is less than or equal to 90, add 10, and then set the music volume in the SWF movie to the increased value.

} else {

_root.movie_sound.setvolume (100);

Otherwise, set the volume to 100, which is the maximum volume.

}

}

Decrease Volume Button:

On (release) {

if (_root.yinliang>=10) {

_root.yinliang = _root.yinliang-10;

_root.movie_sound.setvolume (_root.yinliang);

If the current volume value is greater than or equal to 10, subtract 10, and then set the music volume in the SWF movie to a reduced value.

} else {

_root.movie_sound.setvolume (0);

Otherwise, the volume is set to 0, so there is no sound.

}

}

Finally, when the courseware is released, be sure to put all the SWF files in the same folder, otherwise, when using courseware, will be prompted to call the SWF file can not find.

Special SWF file Invocation tips

Not all SWF files are exactly the same as our invocation requirements, and for some SWF files that do not meet our requirements, we can also set their properties to match our requirements. The following is a description of the three special case handling methods.

1. The size of the SWF file does not match: when the size of the SWF file being invoked is greater than or less than the display area, we can position it precisely by setting the SWF movie's coordinates and dimensions. Examples of statements are as follows:

_root.swf._x=0;

_root.swf._y=0;

Set the values for the horizontal and ordinate of the SWF movie, depending on the situation.

_root.swf._width = 340;

_root.swf.. _height = 300;

Sets the value of the SWF movie's length and width, which can be set in pixels, depending on the situation.

_root.swf._xscale=50;

_root.swf._yscale=50;

Set the SWF movie aspect ratio to the original One-second, the default original size is 100, can be set according to the specific situation.

2. Only part of the SWF file is required: When the previous part of the called SWF file is not needed, we can add a sentence when using the Loadmovie call: _root.swf.gotoandplay (150) (assuming that we need it from 150 frames). When the latter part of the SWF file is not needed, we only need to pause the movie when we play to that part. In fact, when the SWF file is loaded into the movie, all of the movie's control statements can be used to control the SWF file, such as: Transparency (_alpha), Angle (_rotation) and so on.

3. There are special flags in the SWF file: a location in some SWF file may have units or author flags, which can affect the overall effect of the courseware when invoked. At this point, you can add a new layer on top of the SWF film's layer, and then draw your own logo in the corresponding position in the new layer to block the original logo, if the original logo is moving, the logo should also be drawn to the corresponding movement.



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.