Now: Tutorial for Web and Software Design > Flash > Flash Video > Flash Content
> Control Sound Volume with ActionScript [Bookmark it]
Control Sound Volume with ActionScript

This tutorial was written for the Flash Designer software, which allows you to create flash animations in a much easier way than by using Macromedia Flash. You may get Flash Designer here.

Click "Play" and then arrows to adjust sound volume:

Minimum Flash Designer version: 5.0.23.2

Download source project t1052.zip (826 kb)

1. Launch Flash Designer and set movie dimensions 180 x 180 (or any desired).

2. Change frame delay to "Stop".

3. Import sound "sound1.mp3" (Movie > Import Sound)

4. Choose "Frame" > "ActionScript" and paste the code:

mySnd = new Sound();
mySnd.attachSound("sound1.mp3");
volume = 100;

5.Choose "Frame" > "Insert from Gallery" and insert play, stop, up and down buttons.

6. Choose "Movie" > "Insert Flash Designer Clip" and insert "equalizer.sfd" file. Choose "Item" > "Placement Properties" and check "ActionScript Target"

7. Define "OnClick" action for Up arrow:

volume = volume + 10;
if(volume>100) volume = 100;
mySnd.setVolume(volume);

8. Define "OnClick" action for Down arrow:

volume = volume - 10;
if(volume<0) volume = 0;
mySnd.setVolume(volume);

9. Define "OnClick" action for Play arrow:

mySnd.start(0,100);
equalizer.gotoAndPlay("Frame 2");

10. Define "OnClick" action for Stop button:

mySnd.stop();
equalizer.gotoAndPlay("Frame 1");

Hit F9 for preview.


[Bookmark][Print] [Close][To Top]
  • Prev Article-Flash:

  • Next Article-Flash:
  • Related Materias
    Motion Animations
    Shape Transformations
    Effects on Animations
    Introduction to ActionScri
    Examples of ActionScript 2
    Buttons in Flash
    Attaching Movie Clips usin
    Creating the Illusion of S
    Controlling File Size in F
    Introduction to Flash 8
    Topics
    Photoshop Tutorial
     

    Special Effect

      3D Effect
      Photoshop Articles
    Programming Tutorial
     

    C/C++ Tutorial

      Visual Basic
      C# Tutorial
    Database Tutorial
     

    MySQL Tutorial

      MS SQL Tutorial
      Oracle Tutorial
    Graphic Design Tutorial
     

    Coreldraw Tutorial

      Illustrator Tutorial
      3D Graphics Articles
    Webmaster Articles
     

    Domain Service

      Web Hosting
      Site Promotion
    Java Tutorial&Articles
     

    Java Servlets

      JavaEE Tutorial
     

    JavaBeans Tutorial

    XML Tutorial&Articles
     

    XML Style Tutorial

      AJAX Tutorial
      XML Mobile
    Flash Tutorial&Articles
     

    Flash Video

      Action Script
      Flash Articles
    OS Tutorial&Articles
     

    Linux Tutorial

      Symbian Tutorial
      MacOS Tutorial