A scrollable player can move within a visible area that is smaller than its content, allowing the user to scroll through it to view all the content. The scrollable players are pictures, text, and sublets.
The RECT property for a player creates a boundary for the area in which the player image can be seen. The RECT can be larger or smaller than the actual image. If the RECT is smaller than the image, the image can scroll within the RECT, making different parts visible at different times.
For example, to scroll a picture in response to a user's button click, you create a handler on the button. The handler says that each time the mouse clicks on the button, the horizontal scroll point (HSCROLL) property of the picture increments by 10 pixels.
A scrollable player's scroll range depends on its content. For example, if a text field has 100 lines and only 10 fit on the screen, it can scroll a maximum of 90 lines worth of pixels.
To create a scrolling text player, first create and define the properties of the text player:
If you want to use a text file:
Now work with the RECT. The small box in the upper left corner of the Layout window shows the RECT of the text player. Grab a corner of the RECT and stretch it so that it shows the amount of text that you want. That RECT controls the boundary where your text scrolls, so make it as tall or as wide as you want.
Now the player is set up, but you must do something to control the scroll movement of the text. One way to control the movement is to create a handler. Another way is to create a control player.
One simple way to scroll the text player is with user clicks. To do this, put a Handler on the text player so that it scrolls when the user clicks on it:
Close the Handler window and press the Play button to test the mbedlet. With each click, the text should scroll down in the RECT. The VSCROLL increases with every click. Its X,Y points are 0,50, then 0,100, then 0,150, and so on.
Another way to scroll is to create a control player. With the built-in functionality of controls, the value of the control can continuously reset the VSCROLL value for the text, causing the text to scroll smoothly up and down.
If you have created a Handler on the text player, delete it now. Select the whole thing in the Handler window and click the Delete Handler button.
Create a new control player as follows:
Set the following properties:
Property | Set to... |
TYPE | SLIDER |
PROPERTY | VSCROLL |
MIN and MAX | control the value for VSCROLL (in pixels) at both ends of the path. You might have to try different values depending on how large your file is. For example, we used a 22K text file and set MIN=5 and MAX=7500 to be able to scroll to the end. |
PLAYER | (name of your text player) |
CONTINUOUS | yes - so that the value of VSCROLL is updated as the control slides |
STEPSIZE | 5 - so that the value of the control is incremented or decremented by 5 |
(under the Visible tab) VISIBLE | yes |
The Control you created has a straight path by default.
In the Layout window:
Try running the mbedlet. As you slide the control, the text in the text player should scroll.
To add something to represent the "path" for the control,
you can create a picture player with a straight line graphic. Or simply
create a box player that looks like a narrow, straight line.
Previous Page Next Page