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

Flash CS3 Professional Beyond the Basics

Building the progress bar slider


From:

Flash CS3 Professional Beyond the Basics

with Todd Perkins

Video: Building the progress bar slider

Now we'll talk about controlling the progress of our movie clip by dragging the slider inside the Progress bar. If you're following along, I'm working in 13_Controlling_Progress.fla, in the 13 folder, in the Chapter 9 folder, in the Exercise Files folder. First thing we'll do, as usual, set the Publish Settings, ActionScript 3.0 Settings, delete the current class path, set a new class path. Chapter 9, in the 13th folder, Start and then Classes. Once we have our class path set up we'll open the ActionScript files we'll be working with, then we'll navigate to them by going to the Chapter 9 folder, in the 13 folder, Start folder, classes, com, lynda, audio, mp3.
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

Building the progress bar slider

Now we'll talk about controlling the progress of our movie clip by dragging the slider inside the Progress bar. If you're following along, I'm working in 13_Controlling_Progress.fla, in the 13 folder, in the Chapter 9 folder, in the Exercise Files folder. First thing we'll do, as usual, set the Publish Settings, ActionScript 3.0 Settings, delete the current class path, set a new class path. Chapter 9, in the 13th folder, Start and then Classes. Once we have our class path set up we'll open the ActionScript files we'll be working with, then we'll navigate to them by going to the Chapter 9 folder, in the 13 folder, Start folder, classes, com, lynda, audio, mp3.

Then I'm going to select the SoundLoader.as file and I'm going to Cmd click the ProgressSlider.as, that's Ctrl+click on the PC, and then I'll click the Open button to open the files. Let's go to SoundLoader.as. So scroll all the way down to the bottom of the code. What we'll do is create a Public function that will allow us to set the resumeTime from our ProgressSlider instance. So we'll create a Public function called setResumeTime. It will accept one parameter that's going to be time that's going to be a Number and in this functional we will just type resumeTime equals time. So we'll set our resumeTime variable to whatever time is passed in via the time parameter. Now let's save this file by choosing File, Save, then we'll go over to ProgressSlider.as.

The first thing we'll do is create some variables. we'll do this right below our other variables so I'm on line 15 right now and I'm going to create a Private variable. This is called isPlaying and the data type will be Boolean. The isPlaying variable will specify whether the sound should resume playing once we stop dragging the DragSlider. We'll talk more about that a little bit later on in this exercise. Let's scroll down to the bottom of the constructor function and we'll add an EventListener to dragSlider. So type dragSlider.addEventListener and the event will be MouseEvent.MOUSE_DOWN, all caps and we'll run a function called updateProgress.

Ok, let's scroll down to the bottom of our code here and we'll create a Private function called updateProgress. That's going to receive an event with the data type of MouseEvent. The first thing we're going to do in updateProgress function is start dragging the dragSlider Movie Clip. So type dragSlider with capital S, dot startDrag and we'll pass in false, now we'll create a new Rectangle right inside the parameters of this method.

And for the rectangle we're going to pass in an X of zero, a y of the current y position of the dragSlider, then we'll pass in progBar.width minus dragSliders.width for the width of the Rectangle and then for the last value we'll pass in 0 for the hight. Type closed parantheses for both startDrag and the Rectangle. Make sure to type a semicolon in the statement.

Next we'll add an EventListener to the stage of the progressBar, When we release, the Mouse button will stop draging the slide. So type progBar. stage.addEventListener and the event is going to be MouseEvent.MOUSE_UP, all caps, then we'll run a function called stopDraging. Now let's define the stopDragging function. We'll do this right below the updateProgress function, so create a new Private function called stopDragging and that's going to receive an event with the type MouseEvent, and the first thing we'll do is stop dragging the dragSliders so type dragSlider.stopDrag.

Then we'll remove the EventListener for stopDragging so what we'll do is select progBar.stage.addEventListener line of code that we've just wrote and copy using Cmd+C on the Mac or Ctrl+C on the PC and below the stopDrag line of code we'll paste that code that we've just copied by pressing Cmd+V on the Mac or Ctrl+V on the PC. In the pasted code change addEventListener to removeEventListener. Now, when we drag the slider, we want the sound to stop if it's currently playing but we don't want it to stop if it's not currently playing. So let's define that in the updateProgress function. So the very top of the updateProgress function we'll type if and then in parentheses musicPlayer.soundLoader.isPlaying so the sound is currently playing and we want it to stop.

So we'll set isPlaying and that's inside of this class to true then in the next line we'll set musicPlayer.soundLoader.pauseSong and it's in parentheses and a semicolon. So if the sound is currently playing we'll set isPlaying value to true and we'll pause the song else, and we'll set isPlaying= false. So now we've set up our slider so that we can drag it. One problem that's going to happen is that when we drag our slider, the Progress bar is going to try to update the playback of the sound, while we're dragging the slider. So we're going to run into problems there. So what we're going to do is scroll up in our code and find the showProgress function, and we only want to show the progress if the sound is currently playing.

So, above all the code, inside of the showProgress function type if musicPlayer.soundLoader.isPlaying, than we'll just wrap all the code inside of this function in the curly braces. So it will only run if the sound is currently playing and it will be paused when we click to drag the Slider Movie Clip. Now just to make sure that this function is not running when we're trying to drag we're going to turn off the EventListeners for this function. So let's scroll up and find in the Constructor function progBar.addEventListener, event.ENTER_FRAME. That's going to be on line 23 in my code, but it might be under different line in yours. Select that line of code and then copy it using Cmd+C on the Mac or Ctrl+C on the PC.

With the copyed code, scroll down into the updateProgress function. So soon as we click on the slider to drag it we'll all have the Progress of the slider trying to update it in the same time. So let's paste the code at the very bottom of this function by pressing Cmd+V on the Mac or Ctrl+V on the PC and in the pasted code change addEventListener to removeEventListener. Now let's scroll down to the bottom of our code and find the stopDragging function. So go at the very bottom of this function and paste the code using Cmd+V on the Mac or Ctrl+V on the PC. We remove the EventListener while over dragging the slider, then we add the EventListener again when we've released the slider in the stopDragging function. At the very top of this function we'll set the resumetime for the song. In order to set the resumeTime, we need to figure out the procentage that the Slider has been dragged across the progress bar. So let's create a variable inside of the function called dragPercent.

And that's going to be a Number and will set this equal to dragSlider.X divided by and then some parentheses, and in the parentheses we're going to type the maximum range for the dragSlider, and that's going to be progBar.width minus dragSliders.width. Notice that these boundaries are the same as the Rectangle for dragingSlider. On the next line we'll set the resumeTime for the sound. So type musicPlayer dot soundLoader, with capital L, dot setResumeTime.

And then we're going to pass in a value here, and the value we'll pass will be dragPercent times, and here we'll get the total length of the song. So type musicPlayer dot soundLoader, dot getSongLength and some parentheses. So once we stop dragging the slider then we'll set the resume time for the song. The last thing we need to do here is make the song resume playing if it's already playing. So on the next line, create an if statement that checks to see if the isPlaying variable is true.

If the sound was playing when we started dragging it, then we'll type musicPlayer.soundLoader.playSong, with capital S and some parentheses. So if the sound was playing when we started dragging it, it will play again when we stop dragging it. Let's test this all out. Choose File, Save to save the file, and then we'll test movie using Cmd+Return on the Mac or Ctrl+Enter on the PC. click and drag the slider to move it on the stage, then click the Play button to play the song and drag the Slider to navigate to different positions of the song.

And looks like it's working great. So let's close this window and maybe the last thing you'd want to do is just set the buttonMode property of the slider to true so that you see a Hand Cursor and the user of the Mp3 Player knows that you can click and drag that slider. Let's do that as the fishing touch. Scroll at the very top of your code and then at the very bottom of the constructor function type dragSlider with the capital s, dot buttonMode equals true. Let's save the file by choosing File, Save, then test the file with Cmd+return on the Mac or Ctrl+Enter on the PC. When you roll over the slider you see a Hand Cursor.

I'll close the window, so that our slider works and our Mp3 Player works great. Now I just have to say congratulations, you just completed a full object oriented application. Good job.

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