Dynamic Scrollbars in Flash (an Introduction to Components)

A few weeks ago we learned how to load dynamic text in Flash. So what if your external text file has more characters than your text field, or the amount of text fluctuates? (…)

Regular Feature: How-To's Day

A few weeks ago we learned how to load dynamic text in Flash. So what if your external text file has more characters than your text field, or the amount of text fluctuates? Lucky for us Macromedia introduced the scrollbar component in MX 2004, which makes this a breeze. What’s a component you say?

Remember SmartClips from Flash 5 way back when? Components are SmartClips all grown up. Basically a component isn’t much more than a pre-packaged MovieClip with most of the functionality you’ll need already built in. Open your components pane in Flash, Command + F7 for Mac users. You’ll see Flash already comes with many components for Menus, Video Control, and Data Manipulation.

Under User Interface is the UIScrollbar. If you drag this component onto your text field, you’ll see it snaps into place. (Your textfield must be Dynamic, with multiline selected, and an instance name set.) You can edit paramaters such as vertical or horizontal from the Components Inspector. Next create a layer called Actions, if you haven’t already. (I find it best practice to give Actions and Labels their own layers.) On the first frame place the following line of ActionScript:

scrollbarinstancename._visible = (textareainstancename.maxscroll >1);

You just told Flash to make that instance of your scrollbar visible in that text field when the maximum number of scrollable characters is greater than one. That’s it, you’re done. Unfortunately you just added 40k to your movie for every instance of the scrollbar, so if you’re strapped on size you may want to seek out some of the other component options available in the Flash community.

Here are a few resources to get you started:

How-To’s Day is a regular Designorati feature in which we give you fresh tutorials across all of Designorati. How-To’s Day happens every other Tuesday.

Print This Page
Subscribe to the Discussion Surrounding This Article
EMail This Page to a Friend
  1. [...] Dynamic Scrollbars In Flash - an introduction to components tutorial. [...]

    08 April 2006

  2. sorry, just wanted to see if it works in firefox, cuz I didn’t manage to do that myself. By the way, thanks for the tutorial!!!

    27 April 2006

*Enter Your Name (Required)
*Enter Your Email Address (Required and Kept Confidential)
Enter Your Web Address (Optional)
An asterisk (*) in the field name indicates required information.
We reserve the right to edit or delete comments for any reason.