EasyManua.ls Logo

MACROMEDIA FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH - Page 445

MACROMEDIA FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH
830 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
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 thats located in a directory thats on a server. The SWF file that contains this
code might be on your hard disk or on a server.

Table of Contents

Related product manuals