Start learning with our library of video tutorials taught by experts. Get started

Flash CS3 Professional Beyond the Basics

Displaying the current volume


From:

Flash CS3 Professional Beyond the Basics

with Todd Perkins

Video: Displaying the current volume

Now we'll prepare Mp3 Player to be able to control the volume of the songs. If you're following along, I'm working in 10_Setting_Volume.fla, in the 10 folder in the Chapter 9 folder, in the Exercise Files folder. The first thing we'll do is, do our super fun class path set up by clicking the Publish Settings button, than ActionScript 3.0 Settings button and then we'll delete the current class path, browse to a new one and will choose the Chapter 9 folder and 10, start, classes, and click choose, ok and OK to close all the windows. Then we'll open up the ActionScript files we'll be working with for this movie. Choose File, Open and then navigate to the Chapter 9 folder, in the 10 folder, start, classes, com, lynda, audio, mp3 and then I'm going to select SoundLoader and I'm going to Cmd+click VolumeControl, its Ctrl+click on the PC and click Open and it will open both of those files.
Expand all | Collapse all
  1. 3m 30s
    1. Welcome
      1m 20s
    2. Getting the most from this training
      1m 20s
    3. Using the exercise files
      50s
  2. 15m 28s
    1. Managing digital assets
      4m 9s
    2. Creating custom keyboard shortcuts
      5m 1s
    3. Creating custom color swatches
      3m 41s
    4. Creating a custom template
      2m 37s
  3. 14m 38s
    1. Working with variables
      3m 41s
    2. Using functions
      3m 30s
    3. Working with events
      2m 11s
    4. Using event listeners
      2m 42s
    5. Working with arrays
      2m 34s
  4. 29m 41s
    1. Understanding dynamic text fields
      2m 37s
    2. Loading text from an external file
      6m 42s
    3. Reading HTML from a text field
      5m 29s
    4. Applying CSS with ActionScript
      7m 0s
    5. Applying external CSS to a text field
      7m 53s
  5. 45m 27s
    1. Masking dynamic text
      4m 59s
    2. Dragging the Scroll Bar
      7m 3s
    3. Calculating a scroll percent
      5m 20s
    4. Setting scroll boundaries
      4m 9s
    5. Connecting the ScrollBar to the text field
      2m 55s
    6. Easing the text with the ScrollBar
      4m 12s
    7. Scrolling the text with buttons
      2m 38s
    8. Animating the scrolling text with the buttons
      4m 26s
    9. Setting boundaries for the scrolling text
      4m 26s
    10. Easing the text using the buttons
      1m 37s
    11. Connecting the ScrollBar to the Scroll buttons
      3m 42s
  6. 20m 46s
    1. Organizing a complex object into layers
      1m 51s
    2. Duplicating MovieClips
      1m 29s
    3. Undocking the timeline
      1m 20s
    4. Animating a complex MovieClip
      4m 36s
    5. Creating an animated Hinge effect
      5m 13s
    6. Creating complex animations
      6m 17s
  7. 28m 1s
    1. Controlling objects with buttons
      4m 6s
    2. Understanding frame labels
      3m 25s
    3. Using buttons to navigate labeled frames
      2m 30s
    4. Nesting code within MovieClips
      5m 8s
    5. Adding sound to the application
      2m 34s
    6. Adding drag interactivity to the robot
      6m 1s
    7. Animating the dragged robot
      4m 17s
  8. 20m 3s
    1. Understanding components
      2m 30s
    2. Using components to setup a form
      3m 45s
    3. Setting up the form to send an email
      3m 38s
    4. Working with form variables
      6m 11s
    5. Skinning components
      3m 59s
  9. 27m 40s
    1. Using transparency in a video
      4m 16s
    2. Working with embedded video
      3m 38s
    3. Animating a VideoClip
      2m 53s
    4. Creating an advanced animation with video
      2m 40s
    5. Working with the bitmap data class
      3m 37s
    6. Working with the bitmap class
      1m 40s
    7. Copying the video to create a reflection
      1m 35s
    8. Reflecting the video
      2m 42s
    9. Enhancing a video reflection with a mask
      4m 39s
  10. 1h 38m
    1. Viewing the finished MP3 player
      1m 45s
    2. Understanding the project flow
      2m 52s
    3. Preparing to build the MP3 player
      5m 11s
    4. Understanding classes and packages
      5m 32s
    5. Creating the MP3 player class
      9m 59s
    6. Loading sounds from external files
      9m 20s
    7. Accessing ID3 tag information
      6m 11s
    8. Controlling sound playback with Play and Pause buttons
      11m 3s
    9. Changing tracks
      12m 1s
    10. Displaying the current volume
      9m 33s
    11. Changing the volume
      6m 40s
    12. Wiring the progress bar
      8m 4s
    13. Building the progress bar slider
      10m 4s
  11. 5m 36s
    1. Making Flash movies accessible
      1m 49s
    2. Adding a name and description to your Flash movie
      52s
    3. Accessibility and text fields
      2m 55s
  12. 12m 2s
    1. Understanding Flash Mobile
      35s
    2. Exploring Device Central
      1m 45s
    3. Updating Device Profiles
      1m 7s
    4. Creating a Flash file from Device Central
      2m 7s
    5. Creating and testing Flash Lite applications
      2m 48s
    6. Downloading the Flash Lite player for Windows Mobile
      1m 44s
    7. Getting a Flash Lite application onto your phone
      1m 56s
  13. 27s
    1. Goodbye
      27s

Watch this entire course now—plus get access to every course in the library. Each course includes high-quality videos taught by expert instructors.

Become a member
Please wait...
Flash CS3 Professional Beyond the Basics
5h 21m Intermediate Dec 06, 2007

Viewers: in countries Watching now:

Through several hands-on tutorials, instructor Todd Perkins shows how to best build dynamic, streamlined sites using Flash CS3 Professional. Learn how to create custom keyboard shortcuts, apply advanced text techniques such as animating scrolling text with custom easing controls, and using advanced animation techniques. Flash CS3 Professional Beyond the Basics covers many challenging features, including adding complex interactivity to a Flash CS3 project and getting Flash content on a phone. Exercise files accompany the tutorials.

Topics include:
  • Customizing Flash CS3 and managing assets Working with ActionScript variables Understanding dynamic text fields Adding interactivity to dynamic text Animating a complex MovieClip Using buttons to navigate labeled frames Working with components Exploring advanced audio and video techniques Creating accessible Flash content Understanding Flash Mobile
Subject:
Web
Software:
Flash Professional
Author:
Todd Perkins

Displaying the current volume

Now we'll prepare Mp3 Player to be able to control the volume of the songs. If you're following along, I'm working in 10_Setting_Volume.fla, in the 10 folder in the Chapter 9 folder, in the Exercise Files folder. The first thing we'll do is, do our super fun class path set up by clicking the Publish Settings button, than ActionScript 3.0 Settings button and then we'll delete the current class path, browse to a new one and will choose the Chapter 9 folder and 10, start, classes, and click choose, ok and OK to close all the windows. Then we'll open up the ActionScript files we'll be working with for this movie. Choose File, Open and then navigate to the Chapter 9 folder, in the 10 folder, start, classes, com, lynda, audio, mp3 and then I'm going to select SoundLoader and I'm going to Cmd+click VolumeControl, its Ctrl+click on the PC and click Open and it will open both of those files.

The first thing we need to do is create a soundTransform object that we can use to control the volume of our sounds. So at the bottom of the variable sections in the SoundLoader.as file we'll create a new Private variable and we'll call this variable songVolume. The data type will be SoundTransform, capital S for sound, capital T for transform. We'll give this variable a value inside of the songLoaded function. So scroll down to the songLoaded function. Now we're going to give it a value in two places here. That's because the first time we give it a value when we initialize an instance of this class. So find the conditional statement that checks to see if this class is yet initialized.

At the top of that conditional statement we'll set songVolume= song.soundTransform such it initializes the variable to be whatever the current soundTransform value is of our SongChannel object called song. Then it's basically going to give it the default value and the default volume of one and one is the full volume of sound, sound volume goes from zero to one. The next area that we will work with our songVolume variable inside of this function is right below this conditional statement where we'll create an else statement. If this object is already been initialized then what we'll do is we'll set song.soundTransform equal to songVolume.

That way what the new song loads, the new song will adopt all the properties connected to the soundVolume object. That way when a new song is loaded it adopts the same volume as the last song had. Another area where we need to set the volume of our song is when we play our songs. Let's scroll down and find a playSong function. The reason why we need to do this is because we're giving a new value to our song variable our soundChannel object. If we didn't update the song's soundTransform property here it would go back to its default soundTransform property and have a volume of one, which could kind of be annoying if the user turned the volume down a little bit and then clicked to play the sound and the volume went back up to the max volume. So let's go to the next line, right below song= loader.play and then we'll type song. soundTransform= songVolume.

Now that we've connected our song and our songVolume in the right places, let's create some functions that we can use to manipulate the volume of the song. Scroll down at the very bottom of all the functions, create a new function. This is going to be a public function, so type public function and this is going to be called setVol with a capital V short for set volume and it's going to receive a variable called vol and that's going to be a Number, vol is short from volume. It's not going to return any values and what we're going to do in here is simply set songVolume.volume egual to the value that's passed in as vol.

So songVolume.volume= vol. On the next line we'll connect our new volume to our song, so type song.soundTransform= songVolume So we can use this function to set the volume of our sound against public so we can use it in different class files and with different instances. So let's go down a few lines and we'll create another function. This is also going to be a public function and this function is going be used to get the current volume. So call this getVol with capital V and it's not going to receive any value and we'll simply have it return the current value of songVolume.volume.

You can run this function from anywhere and get the current songVolume. In your code, scroll up, and find the initialized area or find the conditional statement that checks to see if this instance has yet been initialized and it's inside of the songLoaded function and on my code is from line 44 to line 50. At the very bottom of this function we'll give a value to musicPlayer.volControl. Remember that's the volume control instance that we created in the Mp3Player class.

So we'll give that a value of new VolumeControl, capital V and capital C and we're going to pass in a few variable values. So the first one is going to be the Volume Movie Clip and that's going to be musicPlayer.volBar. Then we're also going to pass in our Mp3Player instance, which is musicPlayer. Now that we've created a new instance of the VolumeControl class we can start working with the VolumeControl class.

So choose File, Save. And now we'll go over to VolumeControl.as and start defining what this class does. Inside of the VolumeControl class we'll create a few variables or a few properties and they will both be private. So we'll create a private variable called musicPlayer and that we'll be an instance of the Mp3Player class. Then on the next line, we'll create another private variable called volBar and the data type of that will be MovieClip and this is going to represent the volumeBar MovieClip.

Inside of the parentheses for the VolumeControl constructor function we need to receive those two values that we've passed in from SoundLoader.as. Now the first value there was our volumeBar, so I'm just going to call this vBar for short and the data type of course is going to be MovieClip. There are also going to need to accept the Mp3Player instance so we'll call this player and the data type is going to be Mp3Player, and inside of the constructor function we'll initialise the values of our musicPlayer object and our volBar object.

So type musicPlayer equals player and volBar equals the vBar. On the next line we'll set the buttonMode of our volBar object to true. This will make the Hand Cursor show when you roll over that Movie Clip. As long as the Movie Clip is interactive meaning it has mouseEvent listeners associated with it. On the next line we'll make our volumeBar give us some feedback and show what volume the sound is currently playing at, or what the volume is going to be when we press the Play button.

So type volBar.gotoAndStop and in the parentheses I'm going to pass in Math.round and in the parentheses for math.round I'm going to get the current volume, I'm going to multiply that by the total frames in the volBar Movie Clip. What that's going to do is give me some feedback as to where the volume is. For example the volume is going to be in a value between zero and one. The volBar Movie Clip has 10 frames.

So by multiplying the values if the volume is .5, we multiply that value by the total frames of the volBar Movie Clip. Then we make the volBar go to and stop at frame five. So it plays halfway through its animation. It gives us the visual feedback that the volume is halfway up. So on our Math.round I'm going to type musicPlayer. soundLoader.getVol and it's in parentheses times volBar capital B, dot totalFrames.

And that should do it. So let's save the file and test the movie. File, Save to save the file. Test the movie using Cmd+Return on the Mac or Ctrl+Enter on the PC. Now you can see the Volume Slider is no longer animating, shows the Hand Cursor when I roll over it and is showing me some feedback about the current volume, which is a full volume. We'll close the window. So now I associated the volume of our sound with the volumeBar on the stage. The next step is to add interactivity or we can control the sound by dragging the Sound Bar.

There are currently no FAQs about Flash CS3 Professional Beyond the Basics.

Share a link to this course
Please wait... Please wait...
Upgrade to get access to exercise files.

Exercise files video

How to use exercise files.

Learn by watching, listening, and doing, Exercise files are the same files the author uses in the course, so you can download them and follow along Premium memberships include access to all exercise files in the library.
Upgrade now


Exercise files

Exercise files video

How to use exercise files.

For additional information on downloading and using exercise files, watch our instructional video or read the instructions in the FAQ.

This course includes free exercise files, so you can practice while you watch the course. To access all the exercise files in our library, become a Premium Member.

Upgrade now

Are you sure you want to mark all the videos in this course as unwatched?

This will not affect your course history, your reports, or your certificates of completion for this course.


Mark all as unwatched Cancel

Congratulations

You have completed Flash CS3 Professional Beyond the Basics.

Return to your organization's learning portal to continue training, or close this page.


OK
Become a member to add this course to a playlist

Join today and get unlimited access to the entire library of video courses—and create as many playlists as you like.

Get started

Already a member?

Become a member to like this course.

Join today and get unlimited access to the entire library of video courses.

Get started

Already a member?

Exercise files

Learn by watching, listening, and doing! Exercise files are the same files the author uses in the course, so you can download them and follow along. Exercise files are available with all Premium memberships. Learn more

Get started

Already a Premium member?

Exercise files video

How to use exercise files.

Ask a question

Thanks for contacting us.
You’ll hear from our Customer Service team within 24 hours.

Please enter the text shown below:

The classic layout automatically defaults to the latest Flash Player.

To choose a different player, hold the cursor over your name at the top right of any lynda.com page and choose Site preferencesfrom the dropdown menu.

Continue to classic layout Stay on new layout
Welcome to the redesigned course page.

We’ve moved some things around, and now you can



Exercise files

Access exercise files from a button right under the course name.

Mark videos as unwatched

Remove icons showing you already watched videos if you want to start over.

Control your viewing experience

Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.

Interactive transcripts

Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.

Thanks for signing up.

We’ll send you a confirmation email shortly.


Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

Keep up with news, tips, and latest courses with emails from lynda.com.

Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

   
submit Lightbox submit clicked

Terms and conditions of use

We've updated our terms and conditions (now called terms of service).Go
Review and accept our updated terms of service.