当前位置:软件学习 > Flash >>

flash textfield 使用img与html标签教程

在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";

补充:flash教程,As3.0 
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,