Flash sound Effects case selection--channel control

Source: Internet
Author: User
Tags abs

The adjustment of the left and right channel, we often encounter in daily life, but if the use of flash to achieve, not better, in fact, this is also very simple, in flash can be easily achieved in the production process mainly using ActionScript script control, the final playback effect as shown in Figure 1, To achieve this effect, the following steps are:

Fig. 1 Channel control effect

1. Create a new movie, set its size to 200xpx200px (in pixels), set its background color to #cccccc, and of course the user can set it according to the needs. Press "Ctrl+r", the shortcut key opens the Import dialog box, imports a sound file.

2. Create a new movie clip "Drum", select frame 1th, insert a keyframe, and draw a small horn pattern in the workspace, as shown in Figure 2:

Figure 2 Designing the movie clip "Drum"

3. Return to the main scene, insert a key post at the first frame, select the frame, drag and drop the imported music into the workspace, select frame 4th to insert a keyframe, drag the movie clip "drum" to the workspace, and create two instances, named "Lbox" and "Rbox", respectively. Use the Text tool to enter text "Stereo control" between two instances, which is superfluous, of course. can be designed to suit your needs. The effect is as shown in Figure 3:

Figure 3 Designing the main scene

4. Select frame 4th to add the following Actionscrip script:

Direction = _xmouse/2-100;

The horizontal axis of the mouse is subtracted from 100 units after 2, and the value is assigned to the variable direction

s = new Sound ();

Get an instance of a sound object

S.setpan (direction);

Specifies the left and right balance of the sound. Valid values range from 100 to 100, where 100 indicates that only the left channel is used, and 100 indicates that only the right channel is used, while 0 represents an evenly balanced sound between two channels because the direction changes with the mouse position. So moving the mouse can control the channel.

if (Direction < 0) {

With (_root.lbox) {

_yscale = Math.Abs (direction) +100;

Enlarges the dimension of the instance "Lbox" to the absolute value of the direction in the ordinate direction plus 100 units

_xscale = Math.Abs (direction) +100;

Enlarge the size of the instance "Lbox" to the absolute value of direction and 100 units in the direction of the horizontal axis

}

} else

{

With (_root.rbox) {

_yscale = Math.Abs (direction) +100;

Enlarges the dimension of the instance "Rbox" to the absolute value of the direction in the ordinate direction plus 100 units

_xscale = Math.Abs (direction) +100;

Enlarge the size of the instance "Rbox" to the absolute value of direction and 100 units in the direction of the horizontal axis

}

}

5. Insert a keyframe at frame 6th, delete the instance and text in the workspace, and add the following ActionScript script to the post:

gotoAndPlay (4);

Returns frame 4th to enable the loop playback of the movie.

5. Save the work, press "Ctrl+enter" to preview the final effect.

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.