往TextField的htmlText属性添加img标签时的更有趣现象
来源:互联网 发布:如何开通淘宝卖家 编辑:程序博客网 时间:2024/09/21 06:36
TextField的htmlText属性,大家都使用过了。向其添加img标签后,你可以通过src属性添加图片,有趣的是你还可以添加swf影片。但,我刚才在这篇文章里发现更有趣的是,你还可以添加DisplayObject类及其子类!
package {
import flash.display.MovieClip;
import flash.text.TextField;[SWF(width="300", height="200", backgroundColor="#FFFFFF")]
public class main extends MovieClip {
public function main() {
var outerTxt:TextField = new TextField();
outerTxt.border = true;
outerTxt.x = 100;
outerTxt.y = 50;
this.addChild( outerTxt );outerTxt.htmlText = “Outer TextField<img id=’txt’ src=’flash.text.TextField‘ width=’80′ height=’50′ />”;
var innerTxt:TextField = outerTxt.getImageReference(‘txt’) as TextField;
innerTxt.border = true;
innerTxt.text = “Inner TextField”;
}
}
}
如下图,可以在TextField里添加TextField:
通过这种方法向TextField添加DisplayObject时,有一个bug。当img标签前后都没有内容时这个bug就会出现:
package {
import flash.display.MovieClip;
import flash.text.TextField;
import flash.text.TextFormat;[SWF(width="300", height="200", backgroundColor="#FFFFFF")]
public class main extends MovieClip {
public function main() {
var txt:TextField = new TextField();
txt.border = true;
txt.x = 100;
txt.y = 50;
this.addChild(txt);txt.htmlText = “<img id=’img’ src=’flash.display.Sprite’ />”;
trace(txt.getImageReference(‘img’)); // nulltxt.htmlText = ” ” + “<img id=’img’ src=’flash.display.Sprite’ />”;
trace(txt.getImageReference(‘img’)); // [object Sprite]
}
}
}
原文:http://ticore.blogspot.com/2009/03/as3-textfieldhtmltext-trick-bug.html
- 往TextField的htmlText属性添加img标签时的更有趣现象
- 关于flash.text.TextField的htmlText属性值得一提的几点
- img标签的galleryimg属性
- <img> 标签的 alt 属性
- TextField中的属性:text 与 htmlText
- 一个有趣的现象
- 一个有趣的现象
- hibernate的有趣现象
- 一次有趣的现象
- Flex4,textArea控件的htmlText属性
- html<img>标签的usemap属性
- HTML <img> 标签的 usemap 属性
- img标签的alt和title属性
- HTML <img> 标签的 alt 属性
- HTML <img> 标签的 usemap 属性
- img 标签的新属性Srcset应用
- img标签的alt和title属性
- img标签的属性title和alt
- 热部署实现机制
- 在eclipse中将android工程打包成apk
- 百度面试题:求一个已排序的数组中绝对值最小的元素
- tomcat热部署的实现原理
- 2013.1.29正式落户csdn博客
- 往TextField的htmlText属性添加img标签时的更有趣现象
- android:layout_gravity和android:gravity
- jdbc实现MYSQL增删改查巩固练习
- 关于安装UBUNTU雅黑字体的感想
- js中的object类型
- Sicily 1889. Max’s game (优先队列dijkstra、哈希)
- 火石玻璃、冕牌玻璃
- gdb调试中的窗口拆分命令
- 学习笔记——体系结构_乱序执行之Tomasulo算法与记分牌算法