Creating scrolling text 153
For example, the following code embeds a SWF file named animation.swf in the text field named
textField_txt on level 0 and assigns the instance name animation_mc to the movie clip that
contains the SWF file.
_level0.textField_txt.htmlText = "Here’s an interesting animation: <img
src='animation.swf' id='animation_mc'>
In this case, the fully qualified path to the newly create movie clip is
_level0.textField_txt.animation_mc. For example, you could attach the following code to a
button (on the same Timeline as
textField_txt) that would stop the playhead of the embedded
SWF file.
on(press) {
textField_txt.animation_mc.stop();
}
Making hyperlinks out of embedded media
To make a hyperlink out of an embedded JPEG file, SWF file, or movie clip, enclose the
<img>
tag in an
<a> tag:
textField.htmlText = "Click the image to return home<a href='home.htm'><img
src='home.jpg'></a>";
When the mouse is over an image, SWF file, or movie clip that is enclosed by <a> tags, the mouse
pointer turns into a “hand” icon, just like standard hyperlinks. Interactivity, such as mouse clicks
and keypresses, do not register in SWF files and movie clips that are enclosed by
<a> tags.
Creating scrolling text
There are several ways to create scrolling text in Flash. You can make dynamic and input text
fields scrollable by selecting the Scrollable Mode option in the Text menu or the context menu, or
by Shift-double-clicking the text block handle.
You can use the
scroll and maxscroll properties of the TextField object to control vertical
scrolling and the
hscroll and maxhscroll properties to control horizontal scrolling in a text
block. The
scroll and hscroll properties specify the current vertical and horizontal scrolling
positions, respectively; you can read and write these properties. The
maxscroll and maxhscroll
properties specify the maximum vertical and horizontal scrolling positions, respectively; you can
only read these properties.
The TextArea component in Flash MX 2004 provides an easy way to create scrolling text fields
with a minimum of scripting. For more information, see the “TextArea component entry” in
Using Components Help.
To create a scrollable dynamic text block, do one of the following:
• Shift-double-click the handle on the dynamic text block.
• Select the dynamic text block with the Arrow tool, and select Text > Scrollable.
• Select the dynamic text block with the Arrow tool. Right-click (Windows) or Control-click
(Macintosh) the dynamic text block, and select Text > Scrollable.