Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member

Wiring the progress bar

From: Flash CS3 Professional Beyond the Basics

Video: Wiring the progress bar

Now we'll make the Progress bar show the progress of the song playing. If you're following along, I'm working in 12_Showing_Progress.fla in the 12th folder, in the Chapter 9 folder, in the Exercise Files folder. Yet again, we will click the Publish Settings button and then click the ActionScript 3.0 Settings button to lead the current class path, browse to the appropriate class path, in the 12 folder, in the Start folder and the Classes folder and then we will open up the ActionScript files that we'll working with for this movie.

Wiring the progress bar

Now we'll make the Progress bar show the progress of the song playing. If you're following along, I'm working in 12_Showing_Progress.fla in the 12th folder, in the Chapter 9 folder, in the Exercise Files folder. Yet again, we will click the Publish Settings button and then click the ActionScript 3.0 Settings button to lead the current class path, browse to the appropriate class path, in the 12 folder, in the Start folder and the Classes folder and then we will open up the ActionScript files that we'll working with for this movie.

And those are in Chapter 9, in the 12th folder and in the Start classes, com, lynda, audio, mp3, and I'm going to select the SoundLoader file and I'm going to hold Cmd on my keyboard and click the ProgressSlider file and then open the files by clicking the Open button. And now let's go to SoundLoader.as and we'll create some variables. We need two things in order to display the progress for our sound. The length of the sound and the current position of the sound. Now, the first thing we'll do in this file is create a variable to hold the song length. So we'll do that below all of our other variables. I'm working on line 21.

This will be a private variable called songLength, and it's going to be a Number. Now we'll initialise the value of this variable, Once our song finishes loading. So let's scroll down and find the songLoaded function and at the very top of our songLoaded function we'll type songLength equals loader.length. Next we'll define some functions that will give us the progress of the song, and the song length, so scroll down.

We're going to the very bottom of our functions here and we'll create two Public functions. The first one will be called getProg, short for getProgress and it's going to return a Number. And this function is simply going to return song.position, and that gives us how many milliseconds into the song, the song currently is. Below that function we'll define another Public function called getSong with a capital S, Length, with a capital L, and this function will return a number. And it's simply going to return the value of the songLength variable.

And the last thing we need to do before we start working in our ProgressSlider file, is create an instance of the ProgressSlider class. So let's scroll up in our code and what we're looking for is the initialised conditional statement inside of the songLoaded function. At the very bottom of that Conditional statement, type musicPlayer.progSlider with capital S equals new ProgressSlider.

We're going to pass in some values here. The first thing is the ProgressBar so we'll type musicPlayer.progBar. The next value is the slider, so type musicPlayer dot dragSlider and the third value we'll pass in is the musicPlayer itself. Now that we've created an instance of our ProgressSlider, let's define what the ProgressSlider does. So, choose File, Save to save this file. We'll had in over to ProgressSlider.as.

So the first thing we'll do is create some variables or properties inside of this class. These are all going to be private. So the first one's going to be progBar, and that's going to be a Movie Clip. And the next one is going to be our musicPlayer, and that will be instance of the Mp3Player class. The next variable is going to be our dragSlider. It's going to be a Movie Clip.

And the last one we'll create is called ProgPercent. This represents the procent of progress in the song, so is progPercent and the data type is going to be Number. And now our constructor function is going to either receive a few values and the first one is going to be the Progress bar so i'm going to call this pBar, and that's a Movie Clip, and the next value is going be the Draggable Slider, so I'm going to call this drag, that's also a Movie Clip, and the third value is going to be the musicPlayer which we'll call player and the data type is going to be Mp3Player.

Inside of the constructor function we'll initialise some of our variables, so type progBar equals pBar. On the next line type dragSlider equals drag and on the next line type musicPlayer equals player. So now we've connected to some of our variables with the values passed in when an instance of this class is created. So now we can work with the Progress bar and the dragSlider and control sound inside of this class.

The next thing we'll do is go to the next line and add an EventListener to the progBar so type progBar. addEventListener and the event is going to be Event.ENTER_FRAME, all caps. We're going to run a function called showProgress. This is going to display the progress of the sound on the stage. So below the Constructor function we'll define the showProgress function. It's going to be Private and again is called showProgress. It's going to receive an event with the data type of Event.

And the first thing this function is going to do is set the value of our progPercent variable. So type progPercent equals musicPlayer.SoundLoader.getProg. So the current progress or the current position of the sound divided by musicPlayer dot soundLoader, dot getSongLength.

Once we have the progress percent we can move the slider accordingly. So on the next line we'll type dragSlider.X equals progPercent times progBar dot width minus dragSlider dot width. I'm going to wrap the progBar dot width minus dragSlide dot width in parantheses. progBar.width - dragSlider.width represents the maximum value that the dragSlider can move.

The width of the progBar minus the width of the draggable slider. And so that our line, the right edge of the slider width the right edge of the progress bar, and multiplying that value by ProgPercent we'll place the dragSlider in the appropriate place for the position of the sound. Let's test the movie and see this in action. File, Save, to save the file and then Cmd+Return on the Mac to test the movie or Ctrl+Enter on the PC. Click the play button and watch the dragSlider update on the screen.

So now our slider shows the progress of our song.

Show transcript

This video is part of

Image for Flash CS3 Professional Beyond the Basics
Flash CS3 Professional Beyond the Basics

79 video lessons · 25610 viewers

Todd Perkins
Author

 
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

Start learning today

Get unlimited access to all courses for just $25/month.

Become a member
Sometimes @lynda teaches me how to use a program and sometimes Lynda.com changes my life forever. @JosefShutter
@lynda lynda.com is an absolute life saver when it comes to learning todays software. Definitely recommend it! #higherlearning @Michael_Caraway
@lynda The best thing online! Your database of courses is great! To the mark and very helpful. Thanks! @ru22more
Got to create something yesterday I never thought I could do. #thanks @lynda @Ngventurella
I really do love @lynda as a learning platform. Never stop learning and developing, it’s probably our greatest gift as a species! @soundslikedavid
@lynda just subscribed to lynda.com all I can say its brilliant join now trust me @ButchSamurai
@lynda is an awesome resource. The membership is priceless if you take advantage of it. @diabetic_techie
One of the best decision I made this year. Buy a 1yr subscription to @lynda @cybercaptive
guys lynda.com (@lynda) is the best. So far I’ve learned Java, principles of OO programming, and now learning about MS project @lucasmitchell
Signed back up to @lynda dot com. I’ve missed it!! Proper geeking out right now! #timetolearn #geek @JayGodbold
Share a link to this course

What are exercise files?

Exercise files are the same files the author uses in the course. Save time by downloading the author's files instead of setting up your own files, and learn by following along with the instructor.

Can I take this course without the exercise files?

Yes! If you decide you would like the exercise files later, you can upgrade to a premium account any time.

Become a member Download sample files See plans and pricing

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.


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.

Join now "Already a member? Log in

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
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.

Are you sure you want to delete this note?

No

Your file was successfully uploaded.

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.