ActionScript 2.0 Language Reference |
|
|
|
| ActionScript classes > TextField > hscroll (TextField.hscroll property) | |||
public hscroll : Number
Indicates the current horizontal scrolling position. If the hscroll property is 0, the text is not horizontally scrolled.
The units of horizontal scrolling are pixels, while the units of vertical scrolling are lines. Horizontal scrolling is measured in pixels because most fonts you typically use are proportionally spaced; meaning, the characters can have different widths. Flash performs vertical scrolling by line because users usually want to see a line of text in its entirety, as opposed to seeing a partial line. Even if there are multiple fonts on a line, the height of the line adjusts to fit the largest font in use.
Note: The hscroll property is zero-based--not one-based like the vertical scrolling property TextField.scroll.
Availability: ActionScript 1.0; Flash Player 6
The following example scrolls the my_txt text field horizontally using two buttons called scrollLeft_btn and scrollRight_btn. The amount of scroll displays in a text field called scroll_txt. Add the following ActionScript to your FLA or AS file:
this.createTextField("scroll_txt", this.getNextHighestDepth(), 10, 10, 160, 20);
this.createTextField("my_txt", this.getNextHighestDepth(), 10, 30, 160, 22);
my_txt.border = true;
my_txt.multiline = false;
my_txt.wordWrap = false;
my_txt.text = "Lorem ipsum dolor sit amet, consectetuer adipiscing...";
scrollLeft_btn.onRelease = function() {
my_txt.hscroll -= 10;
scroll_txt.text = my_txt.hscroll+" of "+my_txt.maxhscroll;
};
scrollRight_btn.onRelease = function() {
my_txt.hscroll += 10;
scroll_txt.text = my_txt.hscroll+" of "+my_txt.maxhscroll;
};
The MovieClip.getNextHighestDepth() method used in this example requires Flash Player 7 or later. If your SWF file includes a version 2 component, use the version 2 components' DepthManager class instead of the MovieClip.getNextHighestDepth() method.
maxhscroll (TextField.maxhscroll property), scroll (TextField.scroll property)
|
|
|
|