当前位置:首页 > 建站知识
AS工程下 使用TextField的IMG
更新时间:2009.06.22 浏览次数:
在Flash IDE下..我们直接使用txt.html = "这里显示一张库里的图片<img src='库id'/>";即可把库里的图像显示到文本框内,而在AS工程下...我们一样可以做到这样的功能...
package { import flash.display.Sprite; import flash.text.*; public class EmbedImageForTextField extends Sprite { [Embed(source="image.png")] private var yellow:Class; public function EmbedImageForTextField() { var t:TextField = new TextField(); t.htmlText = "这里显示一张库里的图片<img src=’EmbedImageForTextField_yellow’/>"; addChild(t); } } } 使用Embed嵌入图片文件后..
我们一样可以使用img标签的src属性来指定嵌入的图片资源..
不过在指定的时候..需要以"所在类名_变量名"的形式来指定..
上例中:
所在类名为EmbedImageForTextField
变量名为yellow
那指定的时候就需要写为"EmbedImageForTextField_yellow";
