Verify that object snapping is turned on (View > Snapping > Snap to Objects).
3.
Drag a UIScrollBar instance from the Components panel onto the text input field near the side
4.
you want to attach it to. The component must overlap with the text field when you release the
mouse in order for it to be properly bound to the field.
The
_targetInstanceName
text field instance name in the Property and Component inspectors.
Select Control > Test Movie.
5.
The application runs, and the scroll bar scrolls the contents of the text field.
You can also create a UIScrollBar component instance and associate it with a text field at runtime
with ActionScript.
The following code creates a vertically oriented UIScrollBar instance and attaches it to the right
side of a text field instance named MyTextField:
// createClassObject like any other component. Name it vSB.
createClassObject(mx.controls.UIScrollBar, "vSB", 10);
// set the target text field
vSB.setScrollTarget(MyTextField);
// size it to match the text field
vSB.setSize(16, MyTextField._height);
// move it next to the text field
vSB.move(MyTextField._x + MyTextField._width, MyTextField._y);
The following code creates a horizontally oriented UIScrollBar instance and attaches it to the
bottom of a text field instance named MyTextField:
// createClassObject like any other component. Name it hSB.
_root.createClassObject(mx.controls.UIScrollBar, "hSB", 20);
hSB.horizontal = true
// set the target text field
hSB.setScrollTarget(MyTextField);
// size it to match the text field
hSB.setSize(MyTextField._width, 16);
// move it to the bottom of the text field
hSB.move(MyTextField._x, MyTextField._y + MyTextField._height);
Customizing the UIScrollBar component
You can transform a UIScrollBar component horizontally and vertically while authoring and at
runtime. While authoring, select the component on the Stage and use the Free Transform tool or
any of the Modify > Transform commands. At runtime, use the
UIObject.setSize()
830
Chapter 6: Components Dictionary
property of the component is automatically populated with the
) or any applicable properties and methods of the UIScrollBar class.
method (see
setSize()
Need help?
Do you have a question about the FLASH MX 2004-USING COMPONENTS and is the answer not in the manual?