Working with Text and HTML in Flash - Embedding media in text fields
(Page 6 of 6 )
In Flash Player 7 and later, you can use the <img>tag to embed JPEG files, SWF files, and movie clips inside dynamic and input text fields.
To embed a JPEG or SWF file in a text field you need to specify the absolute or relative path to the JPEG or SWF file in the <img>tag’s srcattribute.
Example:
sample_txt.htmlText = "<p>Picture:<img src='pic.jpg'>";
To embed a movie clip symbol in a text field, you specify the symbol’s linkage identifier for the <img>tag’s srcattribute.
Example:
sample_txt.htmlText = "<p>Movie clip:<img src='symbol_ID'>";
You can control the embedded media using ActionScript by specifying the id attribute in the <img> tag.
Flash Player creates a new movie clip for each <img>tag and embeds that movie clip within the TextField object. The movie clip created by Flash Player is added as a child movie clip to the text field that contains the image.
Example:
_root.sample_txt.htmlText =
"SWF: <img src='animation.swf' id='animation_mc'>";
The path of the embedded SWF will be
_level0.
sample_txt
.animation_mc.
_level0.textField_txt.animation_mc.stop(); stops the SWF file.
| DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware. |