Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
Now we'll talk a little bit about classes and packages and what classes we'll be working with. If you're following along find Chapter 9 in the Exercise Files folder and then the 04 folder, and inside of that folder expand the Start folder, and inside of the Start folder expand the Classes folder, expand the com folder, expand the lynda folder, expand the audio folder and expand the mp3 folder. After you've drilled down that many folders you have access to the ActionScript files that are we are working with in this chapter.
Let's take a look at what's inside of each of these files. I'm going to select the top file MP3Player.as, then I'm going to hold Shift on my keyboard and select the bottom file, which is VolumeControl.as. I'm going to drag all of those files over to Flash to open them in Flash. The first file I'm looking at is SoundLoader.as. So find that file and you can just see that it's pretty much a skeleton of a class file. So we have a package definition, and you may remember that a package is just a set of classes and the com.lynda.audio.mp3 is simply the path to where this file is located or the path to this package, the package being com.lynda.audio.mp3.
This package contains all the classes we'll be working with for our MP3 Player project. You can see inside of here, this is simply just the skeleton of a class with just a little bit more and that's just a few import statements. These are the classes that we'll be working with so I just put some import statements in here so if you're following along and don't have access to the Exercise Files you can simply create this SoundLoader.as file with the same code. If you have the same package name you need to also have the same folder structure.
That means the folder called com needs to contain a folder called lynda, which contains a folder called audio, which contains a folder called mp3, which contains this file, SoundLoader.as, as well as the other files that we'll be working with throughout this chapter. So I'm going to close SoundLoader.as. Now we'll take a look at SkipButtons.as. This is simply a class file with some classes imported so I'll close SkipButtons.as. We're going to find MP3 player is essentially the same thing. Several classes are imported and other than that is just a skeleton of a Class file. Same with VolumeControl, Same with the PlayPauseBupon, same with the ProgressSlider and so I close the ProgressSlider and that's a look at the class files we'll be working with. Now if you don't have access to the Exercise Files, and you didn't happen to copy all that code down don't worry we'll go back to those files and you'll be able to see that same code again so you can copy it down then.
So now that we've looked at our classes and talked about what packages are, let's connect our FLA file to those classes or to the com.lynda.audio.mp3 package. So make sure everything on the Stage is deselected and then in the bottom of the screen in the Property inspector I'm going to click the Publish Settings button and that opens up the Publish Settings window and inside of the Publish Settings window I'm going to choose the Flash tab and next to ActionScript version, ActionScript 3.0 I'm going to click the Settings button.
This is where you specify where the class files that you'll be working with are located. So as we looked at earlier in this movie, we have that folder called classes that contains all of our classes and contains that whole folder structure com.lynda.audio.mp3. So what we need do is link this Flash file to that classes folder. So what I'm going to do is click the Target button on the right side near the bottom of the ActionScript 3.0 Settings window, and that's actually the Browse to Path button, looks like a Target icon.
When you click that button Flash points you to select the path that contains the class definition .as files you wish to import. So what I'm going to do is in the Chapter 9 folder, in the Exercise Files folder I'm going to go to Chapter 04 folder and Start folder, I'm going to select the Classes folder. I'm not going to browse all the way down, com and then lynda and then audio and then mp3. I'm just going to choose classes. That's all that you need to choose, everything else we can do in ActionScript. So let's click the Choose button after you've selected that folder.
You can see the class path inside of the Classpath window, and once you've selected your classpath, just click OK and then click OK to exit the Publish Settings window. Now we've told Flash where our class files are stored. The next thing we want to do is import those classes, so we can use them in ActionScript. Select the first keyframe of the Actions layer and open up the Actions panel by pressing Option+F9 on the Mac or F9 on the PC. Inside of the Actions panel, above all the other code that's previously written, type import. We're going to need to import all those classes. We're going to be doing it using that same Package structure or the Folder structure that was specified in each class.
So we're going to import the entire, com.lynda.audio.mp3 class. To do that we type com.lynda.audio.mp3 and then .*. That's the wild card that imports all the classes that we'll be working with to build our MP3 Player. And now all of our classes are ready and waiting for us to work with them.
Get unlimited access to all courses for just $25/month.Become a member
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
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.
Your file was successfully uploaded.