How to Put a Scroll Bar in a Flash Document

Putting a scroll bar in a Flash document gives you the framework for creating inline word processing applications and vast libraries of easily accessible images, animations and videos. You can put a Flash scroll bar into a Flash document in a variety of different ways. One way is using the Flash ActionScript 3.0 programming language. Placing the scrollbar however won't be enough to test your scrollbar. For that you will need to have a text field with text in it to scroll.

Things You'll Need

  • Adobe Flash Professional: CS3, CS4 or CS5 Versions
Show More

Instructions

    • 1

      Click "New" from the File menu on the main Flash menu bar. Click the file type "Flash File(ActionScript 3.0)" in the New Document dialog box that appears. Click the "OK" button to close the dialog box.

    • 2

      Click to select the "Actions" option from the Window menu on the main Flash menu bar to open the Actions editor. Position your mouse cursor on the first line of the Actions editor. Click your mouse button and type in the code, below, to load the necessary Flash utilities to use the scrollbar component.

      import fl.controls.UIScrollBar;

    • 3

      Type the code, below, starting at the next line in the Actions editor to create a TextField that the scroll bar will use to scroll.

      var textOne:TextField = new TextField();

      textOne.border = true;

      textOne.width = 100;

      textOne.height = 20;

      textOne.x = 200;

      textOne.y = 150;

    • 4

      Type the code, below, starting at the next line in the Actions editor to create a horizontal scrolling scroll bar that has the same width as the TextField previously created and is placed directly below it.

      var scrollOne:UIScrollBar = new UIScrollBar();

      scrollOne.direction = "horizontal";

      scrollOne.setSize(textOne.width, textOne.height);

      scrollOne.move(textOne.x, textOne.height + textOne.y);

    • 5

      Type the code, below, starting at the next line in the Actions editor to place text into the TextField, place the TextField and the scroll bar on the Flash stage, and attach the TextField to the scroll bar for scrolling (scrollTarget).

      addChild(textOne);

      addChild(scrollOne);

      textOne.text = "The brown fox jumped over the white fence and then ran through the hills.";

      scrollOne.scrollTarget = textOne;

    • 6

      Copy and paste the code, below, into the Actions editor if you want to run the scroll bar program error-free.

      import fl.controls.UIScrollBar;

      var textOne:TextField = new TextField();

      textOne.border = true;

      textOne.width = 100;

      textOne.height = 20;

      textOne.x = 200;

      textOne.y = 150;

      var scrollOne:UIScrollBar = new UIScrollBar();

      scrollOne.direction = "horizontal";

      scrollOne.setSize(textOne.width, textOne.height);

      scrollOne.move(textOne.x, textOne.height + textOne.y);

      addChild(textOne);

      addChild(scrollOne);

      textOne.text = "The brown fox jumped over the white fence and then ran through the hills.";

      scrollOne.scrollTarget = textOne;

    • 7

      Click the "TestMovie" option in the Control menu on the main Flash menu bar to play the movie. Position your mouse over the horizontal scroll bar to scroll right to view the text that is not visible.

Learnify Hub © www.0685.com All Rights Reserved