先看一大段测试代码,每个小方法的注释行是输出结果。

private var text_content:TextField;

private function textFieldDemo():void{
text_content=new TextField();
addChild(text_content);
textFieldDemo26();
}

private function textFieldDemo1():void{
trace(text_content.width);
text_content.text="nihao";
trace(text_content.width);
text_content.autoSize="left";
trace(text_content.width);
//text正常显示,输出100 100 30
}

private function textFieldDemo12():void{
text_content.multiline=true;
trace(text_content.width);
text_content.text="nihao";
trace(text_content.width);
text_content.autoSize="left";
trace(text_content.width);
//text正常显示,输出100 100 30
}

private function textFieldDemo13():void{
text_content.wordWrap=true;
trace(text_content.width);
text_content.text="nihao";
trace(text_content.width);
text_content.autoSize="left";
trace(text_content.width);
//text正常显示,输出100 100 100
}

private function textFieldDemo14():void{
trace(text_content.width);
text_content.text="nihao";
trace(text_content.width);
text_content.autoSize="left";
trace(text_content.width);
text_content.wordWrap=true;
trace(text_content.width);
//text正常显示,输出100 100 30 30
}

private function textFieldDemo15():void{
text_content.width=222;
text_content.wordWrap=true;
trace(text_content.width);
text_content.text="nihao";
trace(text_content.width);
text_content.autoSize="left";
trace(text_content.width);
//text正常显示,输出222 222 222
}

private function textFieldDemo16():void{
text_content.text="nihao";
trace(text_content.width);
text_content.wordWrap=true;
trace(text_content.width);
text_content.autoSize="left";
trace(text_content.width);
//text正常显示,输出100 100 100
}

private function textFieldDemo2():void{
trace(text_content.width);
text_content.autoSize="left";
trace(text_content.width);
text_content.text="nihao";
trace(text_content.width);
//text正常显示,输出100 4 30
}

private function textFieldDemo22():void{
text_content.multiline=true;
trace(text_content.width);
text_content.autoSize="left";
trace(text_content.width);
text_content.text="nihao";
trace(text_content.width);
//text正常显示,输出100 4 30
}

private function textFieldDemo23():void{
text_content.wordWrap=true;
trace(text_content.width);
text_content.autoSize="left";
trace(text_content.width);
text_content.text="nihao";
trace(text_content.width);
//text正常显示,输出100 100 100
}

private function textFieldDemo24():void{
trace(text_content.width);
text_content.autoSize="left";
trace(text_content.width);
text_content.text="nihao";
trace(text_content.width);
text_content.wordWrap=true;
trace(text_content.width);
//text正常显示,输出100 4 30 30
}

private function textFieldDemo25():void{
text_content.width=222;
text_content.wordWrap=true;
trace(text_content.width);
text_content.autoSize="left";
trace(text_content.width);
text_content.text="nihao";
trace(text_content.width);
//text正常显示,输出222 222 222
}

private function textFieldDemo26():void{
text_content.width=222;
text_content.autoSize="left";
trace(text_content.width);
text_content.wordWrap=true;
trace(text_content.width);
text_content.text="nihao";
trace(text_content.width);
//text"不显示"(界面上看不到textfield),输出4 4 4
}

仔细分析上面的代码执行结果,可以得出如下结论:

1.设置wordwrap,mulitline不会导致width值发生变化,但设置wordwrap可能会对width的值产生影响。

2.设置autosize属性,当wordwrap为false时导致width值发生变化,当wordwrap为true时不对width产生影响。

3.设置text属性,当wordwrap为false并且autosize不为none时,width值才发生变化。否则不对width产生影响。

就是说,wordwrap autosize text对width都有决定作用。

神奇的TextField(1)的更多相关文章

  1. 神奇的TextField(2)

    var text_content:TextField=new TextField(); text_content.autoSize="left"; // text_content. ...

  2. ios设置textField只能输入数字用于电话号码

    首先在.xib中将UITextField的Keyboard设置为Number Pad,但是使用时键盘会切回别的键盘无法对内容进行校验.通过神奇的百度我知道了通过以下方法可以解决这样的问题: 首先让.x ...

  3. 模型层字段-多表查询-神奇的双下划线查询-F,Q查询

    Django ORM中常用的字段和参数 常用字段 AutoField int自增列,必须填入参数 primary_key=True.当model中如果没有自增列,则自动会创建一个列名为id的列. In ...

  4. BZOJ 1006 【HNOI2008】 神奇的国度

    题目链接:神奇的国度 一篇论文题--神奇的弦图,神奇的MCS-- 感觉我没有什么需要多说的,这里简单介绍一下MCS: 我们给每个点记录一个权值,从后往前依次确定完美消除序列中的点,每次选择权值最大的一 ...

  5. 前端精选文摘:BFC 神奇背后的原理

    BFC 已经是一个耳听熟闻的词语了,网上有许多关于 BFC 的文章,介绍了如何触发 BFC 以及 BFC 的一些用处(如清浮动,防止 margin 重叠等).虽然我知道如何利用 BFC 解决这些问题, ...

  6. TextField和TextView的限制输入长度

    TextField的限制代理方法 只需要在这个代理方法里面code这样的代码就可以了 16 是长度可以自己设置 - (BOOL)textField:(UITextField *)textField s ...

  7. MVC系列——MVC源码学习:打造自己的MVC框架(四:了解神奇的视图引擎)

    前言:通过之前的三篇介绍,我们基本上完成了从请求发出到路由匹配.再到控制器的激活,再到Action的执行这些个过程.今天还是趁热打铁,将我们的View也来完善下,也让整个系列相对完整,博主不希望烂尾. ...

  8. 一行神奇的javascript代码

    写本篇文章的缘由是之前群里@墨尘发了一段js代码,如下: (!(~+[])+{})[--[~+""][+[]]*[~+[]] + ~~!+[]]+({}+[])[[~!+[]]*~ ...

  9. [翻译svg教程]Path元素 svg中最神奇的元素!

    先看一个实例 <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999 ...

随机推荐

  1. POJ - 2762 Going from u to v or from v to u? (强连通缩点+判断单向连通)

    题意:判断一个有向图中的任意两点u.v,是否可以由其中一个点到达另一个点. 分析:这个问题转化以后就是:将该图强连通缩点后再判断其是否是单向连通的.缩点用Tarjan处理强连通分量. 有一个定理是这样 ...

  2. flex graphiclar symbol的不同比例尺切换

    private var cityGraL:GraphicsLayer;//标记城市 maxScale=50000 private var siteGraL:GraphicsLayer;//标记站点 m ...

  3. dogo 官方翻译 Ajax with dojo/request

    require(["dojo/request"], function(request){ request("helloworld.txt").then( fun ...

  4. sublime text3 破解, 中文乱码支持, 设置

    1. 激活 菜单: Help -> Enter License, 弹出对话框输入激活码确认(Use License):如下图:. 激活码: ----- BEGIN LICENSE ----- A ...

  5. 不可忽视的技术趋势:Blockchain

    提到blockchain,估计很多人还很陌生,但是提到比特币,很多人就会"哦!就是那个大骗局!"... 比特币的未来搁置不谈(我也不看好).但是比特币的技术基础:blockchai ...

  6. MVC bootstrap 实现 bootstrap table 左右传递数据

    源码: @{ ViewBag.Title = "Index"; } @using BC.Platform.UPMS.Models; <!DOCTYPE html> &l ...

  7. springboot处理session生命周期

    在使用springboot开发过程中发现用户登陆后60s后session就自动失效了,需要重新登陆,明明 application.yml  文件里已经配置了 server.session.timeou ...

  8. Python基础笔记系列二:分支和循环

    本系列教程供个人学习笔记使用,如果您要浏览可能需要其它编程语言基础(如C语言),why?因为我写得烂啊,只有我自己看得懂!! 分支:即是if-else和if-elif-else语句 循环:即是whil ...

  9. 给定字符串数组,用map的key保存数组中字符串元素,value保存字符串元素出现次数,最后统计个字符串元素出现次数

    import java.util.HashMap; public class map1 { public static void main(String[] args) { String[] arra ...

  10. Aizu 2677 Breadth-First Search by Foxpower LCA+bfs

    A - Breadth-First Search by Foxpower Problem Statement Fox Ciel went to JAG Kingdom by bicycle, but ...