OK, I just spent a couple of hours sorting this out, but it works for me in Flash and Flex.
Display images in TextField
DisplayObjects TextField <img />, MovieClips, Sprites .
Flash Flex, , -, DisplayObject (, Sprite MovieClip).
, , . , , TextField .
Flash
: .
TextField . , txtImageTest.
txtImageTest , . 300x150px.
MovieClip , . imageClip1.
- imageClip1.
, ActionScript .
:
imageClip1.wordWrap = true;
imageClip1.multiline = true;
imageClip1.htmlText = "<p>You can include an image in your HTML text with the <img> tag.</p><p><img id='testImage' src='imageClip1' align='left' width='30' height='30' hspace='10' vspace='10'/>Here is text that follows the image. I'm extending the text by lengthening this sentence until it long enough to show wrapping around the bottom of the image.</p>"
.
Flex
MovieClip , Flash, , ( Flash, ).
, BlackArrow.as:
package embed
{
import flash.display.Sprite;
import mx.core.BitmapAsset;
public class BlackArrow extends Sprite
{
[Embed(source='assets/embed/triangleIcon_black.png')]
[Bindable]
private var TriangleImage:Class;
public function BlackArrow()
{
super();
var image:BitmapAsset = new TriangleImage();
addChild(image);
}
}
}
.. ( Flash) BitmapAsset ( Flex), TextField. Sprite - .
, TextField:
<?xml version="1.0" encoding="utf-8"?>
<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml"
width="100%" height="100%">
<mx:Script>
<![CDATA[
import embed.BlackArrow;
// You must include a variable declaration of the same type as your
// wrapper class, otherwise the class won't be compiled into
// the SWF and you will get an IOError.
private var img2:BlackArrow;
]]>
</mx:Script>
<mx:Text id="txtResults1" width="100%" height="100%">
<mx:htmlText>
<![CDATA[<p>You can include an image in your HTML text with the <img> tag.</p><p><img id='testImage' src='embed.BlackArrow' align='left' hspace='10' vspace='10'/>Here is text that follows the image. I'm extending the text by lengthening this sentence until it long enough to show wrapping around the bottom of the image.</p>]]>
</mx:htmlText>
</mx:Text>
</mx:VBox>
, src .
, align . , .
, , :
http://blog.coursevector.com/notes-htmltext
TextField LiveDoc :
http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/text/TextField.html
getImageReference() - , , :
http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/text/TextField.html#getImageReference%28%29
, src.
- , -, , SWF.