一聚教程网:一个值得你收藏的教程网站

最新下载

热门教程

flash textfield 使用img与html标签教程

时间:2009-06-06 编辑:简简单单 来源:一聚教程网

在Flash IDE下..我们直接使用txt.html = "这里显示一张库里的图片";即可把库里的图像显示到文本框内,而在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 = "这里显示一张库里的图片";  

     addChild(t);  

          }    

       }  

  }  使用Embed嵌入图片文件后..
我们一样可以使用img标签的src属性来指定嵌入的图片资源..
不过在指定的时候..需要以"所在类名_变量名"的形式来指定..
上例中:
所在类名为EmbedImageForTextField
变量名为yellow
那指定的时候就需要写为"EmbedImageForTextField_yellow";

热门栏目