New Feature: Playlist Center! Pick a topic and let our playlists guide the way.

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

Flash CS3 Professional Beyond the Basics
Illustration by

Dragging the Scroll Bar


From:

Flash CS3 Professional Beyond the Basics

with Todd Perkins

Video: Dragging the Scroll Bar

Now we'll take a look at dragging the scrollbar. If you're following along,. I'm working in 02_Dragging.fla in the Chapter 04 folder in the Exercise Files folder. On the stage, make sure the buttons layer is unlocked and select the scrollbar on the stage. Note that the scrollbar's Instance Name is scroller_mc and it's an instance of mcScroller. The scrollbar here is just a simple rectangle inside a movie clip. Also on the Buttons layer note the line background for the scrollbar. It's an instance of movie clip called mcLine and it's Instance Name is line_mc.
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

Dragging the Scroll Bar

Now we'll take a look at dragging the scrollbar. If you're following along,. I'm working in 02_Dragging.fla in the Chapter 04 folder in the Exercise Files folder. On the stage, make sure the buttons layer is unlocked and select the scrollbar on the stage. Note that the scrollbar's Instance Name is scroller_mc and it's an instance of mcScroller. The scrollbar here is just a simple rectangle inside a movie clip. Also on the Buttons layer note the line background for the scrollbar. It's an instance of movie clip called mcLine and it's Instance Name is line_mc.

Now let's look at the first keyframe in the actions layer and open up the Actions panel by pressing Option+F9 on the Mac, or F9 on the PC. In the Actions panel scroll down to the bottom of your code and find the code written on line 27, scroller_mc.addEventListener(MouseEvent.MOUSE_DOWN, and then it will run a function called dragScroller. So as soon as your mouse goes down over the scroller_mc movie clip, a function will run called dragScroller. Now that function has already been defined for you if you have access to the Exercise Files.

Let's scroll up and find the dragScroller function. In my code it starts on line 10 and ends on line 13. Inside of the curly braces of this function we're going to specify the boundaries for dragging the scroller movie clip. We need to specify boundaries of the user can't drag the scrollbar all over the screen. To specify drag boundaries, we need to create a rectangle. Now if you've never worked with rectangles before in Flash that may seem kind of confusing, but actually Flash only wants four parameters when you create rectangle. Flash wants the rectangle's x position, y position, width and height.

So let's create variables to hold those values. So I'm going to create a variable called dragX, with a capital X. The data type is going to be Number. This is going to be the x position of the drag boundary for my scrollbar. The value I'm going to pass in is line_mc.x. If I simply have that value here, then x boundary of the scrollbar will be aligned with the x position of the line movie clip. What that will look like on the stage is that the left edge of the scroller will be aligned with the left edge of the line.

What we want is the scrollbar and the line to be center aligned. So we're going to need to write some more code to have Flash center align these two movie clips. After line_mc.x type minus scroller_mc. width divided by two and a semicolon. This shifts the x position of the scroller movie clip to the left, half of the scroller's width. So think about how that works. The entire scrollbar is on the right side of the line.

By subtracting half of the scrollbar's width, the scrollbar becomes centered with the line. Let's create the next line and create a variable to represent the drag or rectangle's y position. We'll call this dragY, capital Y. The data type will also be Number and we'll set this equal to line_mc.y. Now this will specify the highest amount that you can drag the scrollbar up. Here setting the value line_mc.y tells Flash to not let the user drag the scrollbar above the top edge of the line.

And that's the exact value that we want there. Let's go to the next line and now we'll specify the drag width. So create a variable called drag and then capital W. The data type will also be Number and here we'll set the value to 0. We don't want to be able the drag the scrollbar left or right at all. We only want to be able to drag it up and down. Let's go to the next line and create a variable called drag and capital H. This will also be a Number. And this value will specify the height of our rectangle. Now we want it to be close to the same height as the line_mc.

So we'll type line_mc.height. And then we'll subtract scroller_mc.height and that will align the bottom edge of the line with the bottom edge of the scrollbar. So that's as far as the scrollbar down. Let;s go down a few lines and now we'll make our scrollbar draggable. Type scroller_mc.startDrag with a capital D. Passing a value of false here will not lock the registration point of the scroller movie clip to your mouse position when you click and drag.

That way user can click and drag the scrollbar from anywhere the user wants to. If we pass in a value true, the top left of the scroller movie clip would be connected to the user's mouse, which would be kind of awkward. So let's keep a value of false. I'll type a comma and a space. In the second parameter Flash wants a rectangle, and a rectangle is what specifies the drag boundaries. And we created variables for all those boundaries already so it'll be nice and easy to create a rectangle now. Type in new Rectangle, with a capital R. And then ( and notice in the code hinting that Flash tells you four parameters that you need to create a rectangle - the x position, y position, width and height.

We'll just pass in the variables that we created for these values. So type dragX, with a capital X, dragY with a capital Y, dragW with a capital W, dragH capital H. Close out the parentheses for both the rectangle and start drag. Semicolon to end the statement and let's test the movie and drag the scroller movie clip. Command+Return on the Mac, Ctrl+Enter on the PC. I'm dragging the scrollbar down. You may have noticed that the scrollbar slipped a little bit to the left, when I clicked and dragged it.

I'm going to close the Preview window. That's actually a bug with the start-drag method when you specify boundaries. So what I'm going to do is click right at the end of the dragX line of code. I'm going to add 1. Now I'm going to test the movie again, Command+Return on the Mac, Ctrl+Enter on the PC. Now when I click and drag the scrollbar, it doesn't shift the left. You may have noticed when you tested the movie that when you release your mouse button to scroller movie clip never stops dragging. So what we'll do on the next line of code, we'll add an event listener to the stage, so that anywhere you release your mouse in the stage will stop dragging the scroller movie clip.

So Type stage.addEventListener, capital E, capital L for listener. And I'll pass in MouseEvent, capital M, capital E, .MOUSE_UP, all caps and we'll run a function called stopDragging, capital D. Below the dragScroller function, let's create the stopDragging function. So create a function called stopDragging. Make sure it receives an event with the data type of MouseEvent and inside of the stop drag function type scroller_mc.stopDrag with a capital D. Then type some parentheses and a ; to end the statement.

Now we'll test the movie using Command+Return on the Mac, Ctrl+Enter on the PC. Click and drag the scrollbar to move it up and down. Release your mouse anywhere on the stage and the scrollbar stops dragging. I'll close the Preview window now. And there's a look at controlling boundaries for dragging a movie clip.

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

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

join now 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
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

Notes cannot be added for locked videos.

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.