Hide/View the Scrollbar Component
         by Aaron Noriega (aka norie)

Whether it's an input or dynamic text box, many people dread the look of a disabled scrollbar. This tutorial will teach you how to apply a simple code to make the scrollbar invisible when it's not being used.

[ Type Enough Text to Make the Boxes Scroll ]

Steps to Create Animation
The following steps will help you to create the animation you see above:

  1. Create a new input box, name it textBox, and change the line type to Multiline.

[ example of an image ]

  1. Drag the scrollbar component onto the input box; give the scrollbar an instance name of scroll1 and make sure the target text field is textBox.

[ example of an image ]

  1. Now, it's time to make the second text box, but this time we're going to make it dynamic; with an instance name of textBox2 and the line type set to Multiline.

[ example of an image ]

  1. Repeat the process of adding a scrollbar. This time with an instance name of scroll2 and a target text field of textBox2

[ example of an image ]

  1. The last design step: make a button--similar to the one above, if you wish. And place it between the two text boxes.
  2. Now it's time to get our hands dirty with some Actionscript. Add the following code to frame 1 (there should only be one frame).

  1. The final step is to add the following AS to the button.

Code Explanation

_parent.textBox2.text = _parent.textBox.text;
Set the text in the bottom text box (textBox2) equal to the text in the top text box (textBox).

A numeric text box property, that indicates the max value of the property scroll. If this value is 1, the associated scrollbar is disabled. If maxscroll is greater than 1, the scrollbar is enabled.

An action that is called whenever the associated text box is modified.

The scrollbar component has been excluded from MX 2004, but the scrollbar component can be taken from any MX fla that includes the component:

Download Source for MX

If you have any questions, please post them on the kirupaForum.




kirupa.com's fast and reliable hosting provided by Media Temple.