Using HTML-formatted text
445
About embedding images, SWF files, and movie clips
in text fields
In Flash Player 7 and later, you can use the
<img>
tag to embed image files (JPEG, GIF,
PNG), SWF files, and movie clips inside dynamic and input text fields, and TextArea
component instances. (For a full list of attributes for the
<img>
tag, see
“Image tag”
on page 439
.)
Flash displays media embedded in a text field at full size. To specify the dimensions of the
media you are embedding, use the
<img>
tag’s
height
and
width
attributes. (See
“About
specifying height and width values” on page 447
.)
In general, an image embedded in a text field appears on the line following the
<img>
tag.
However, when the
<img>
tag is the first character in the text field, the image appears on the
first line of the text field.
Embedding SWF and image files
To embed an image or SWF file in a text field, specify the absolute or relative path to the
image (GIF, JPEG, or PNG) or SWF file in the
<img>
tag’s
src
attribute. For example, the
following example inserts a GIF file that’s located in the same directory as the SWF file (a
relative address, on or offline).
Embedding an image in a text field:
1.
Create a new Flash document, and save it as
embedding.fla
.
2.
Add the following ActionScript to Frame 1 of the main Timeline:
this.createTextField("image1_txt", 10, 50, 50, 450, 150);
image1_txt.html = true;
image1_txt.htmlText = "<p>Here's a picture from my vacation:<img
src='beach.gif'>";
The preceding code creates a new dynamic text field on the Stage, enables HTML
formatting, and adds some text and a local image to the text field.
3.
Add the following ActionScript below the code added in the previous step:
this.createTextField("image2_txt", 20, 50, 200, 400, 150);
image2_txt.html = true;
image2_txt.htmlText = "<p>Here's a picture from my garden:<img
src='http://www.helpexamples.com/flash/images/image2.jpg'>";
You can also insert an image by using an absolute address. The preceding code inserts a
JPEG file that’s located in a directory that’s on a server. The SWF file that contains this
code might be on your hard disk or on a server.
Содержание FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH
Страница 1: ...Learning ActionScript 2 0 in Flash...
Страница 8: ...8 Contents...
Страница 18: ...18 Introduction...
Страница 30: ...30 What s New in Flash 8 ActionScript...
Страница 66: ...66 Writing and Editing ActionScript 2 0...
Страница 328: ...328 Interfaces...
Страница 350: ...350 Handling Events...
Страница 590: ...590 Creating Interaction with ActionScript...
Страница 710: ...710 Understanding Security...
Страница 730: ...730 Debugging Applications...
Страница 780: ...780 Deprecated Flash 4 operators...
Страница 830: ...830 Index...