Dynamic Text with scrollbar

 

The purpose is to import in a movie a file text in a directory and to allow the scrolling of the text thanks to a vertical scrollbar. This example 'll use pretty easy scripts. I suppose you know well how to create objects, thus I will not insist on.

⇒ animation ⇐

Warning :
This example 'll use a PHP script (server side).
Then, to test your creation, you 'll need :
- either an Apache web server set on your computer ( with PHP installed )
- either put your files on your web directory , provide that your host allows PHP scripting.

At first download a file containing 3 images and a text file. .
Unzip the file in your SwishMax work directory.

Aims

In an animation 640x480, we gonna create a frame which a text 'll be displayed in.
A vertical scrollbar 'll allow the text to scroll.
It owns :
- up and down buttons to go one line up and down.
(also available with up and down arrow keys from the keyboard)
- a lift which 'll move up or down according to previously mentioned.
When clicking rectangular zones above or below the lift, we 'll move 5 lines.
(also available with Page Up and Page Down keys from the keyboard)

Creating Objects

1 - Set up width 640, height 480 and the background color #000066.
Frame Rate doesn't matter.

2 - Create now a rectangle (color #7C72FC), named Cadre with a border of thickness 3, color #DDDDDD.
You 'd yield :

Rectangle    Transform

This rectangle is the background frame for the text.

3 - Now, import image down.gif

image    Transform

Convert to button.

Button    Outline

We 'll use this button to scroll one line.

4 - Now, import image up.gif

image    Transform

Convert to button.

Button    Outline

We 'll use this button to scroll one line.

5 - Now, create a rectangle (color #7C72FC), named downside

You'd yield :

Rectangle    Transform

We 'll use this button to scroll five lines.

6 - Now, create a rectangle (color #7C72FC), named upside

You'd yield :

Rectangle    Transform

We 'll use this button to scroll five lines.

7 - Now, import image lift.gif

image   Transform

We 'll use it as a lift

8 - Right now, the sensitive part : dynamic text (color #FFFF00). It took me a while to get it working.

Transform    Advanced

Pay attention to the stages : Advanced, Dimensions, Formatting.

Dimensions   Formatting

It's fundamental to understand that the control variable scrolltext has got a different name from the object named txt.

Leading allows to modify distance between lines without respect of the font features.

Outline 'd look like

Outline

PHP Script

With a text editor, you 'll enter the following text :

Save it as getfile.php. Upload it on the Web server.

Explanations :
We read the specified file. Then we load the content in a buffer. We handle accents ( optional ).
We get the content of the dynamic variable scrolltext and fini.

SwishMax Scripts

Here is the script for Scene_1

Script for scrolldown

Script for scrollup

Script for downside

Script for upside

Et voilà, that's it.

It would be necessary to improve the scrollbar while determining number of lines of the text, then calculating the step of displacement of the lift so that it 'll reach the bottom when the end of the text is displayed. Well, I 'm nitpicking.

 


Si vous aimez le site

 

Select a language if you need :


Page chargée en 0.083 sec.

Dernière Modification : Mer 25 Janvier 2017 8:56
Copyright © 1999-2017 Jean-Paul Molina Tous droits réservés.

to Google