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

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. 【转】Matlab使用过程中内存不足问题的总结

    使用matlab过程中经常会出现内存不足的问题,这里转载一篇来自http://blog.csdn.net/xiaojidan2011/article/details/8089532 的博文,解决这一问 ...

  2. 浏览器 Event对象 及 属性 的兼容处理

    摘自: http://blog.csdn.net/jiachunfeng/article/details/6448186 event对象 IE 中可以直接使用 event 对象,而 FF 中则不可以, ...

  3. Kali更新源,亲测目前可用的源

    kali更新的时候老是无法定位软件包,网络上大部分中科大.阿里云kali源都不可用,都千篇一律,最后找了这个,网易的,还不错,贴出来大家看看: # 源 deb http://mirrors.163.c ...

  4. 并发-CopyOnWrite源码分析

    CopyOnWrite源码分析 参考: https://blog.csdn.net/linsongbin1/article/details/54581787 http://ifeve.com/java ...

  5. Bellman-Ford算法优化

    2017-07-27 16:02:48 writer:pprp 在BEllman-Ford算法中,其最外层的循环的迭代次数为n-1,如果不存在负权回路,需要迭代的次数是远远小于n-1; 如果在某一次迭 ...

  6. 一篇看懂++i i++

    /** * @Title:Test03 * @Description: * @author Crazy-ZJ * @data 2017年9月28日上午9:38:00 * @book 疯狂java讲义( ...

  7. Codeforces Beta Round #17 D.Notepad 指数循环节

    D. Notepad time limit per test 2 seconds memory limit per test 64 megabytes input standard input out ...

  8. BZOJ 1492 [NOI2007]货币兑换Cash:斜率优化dp + cdq分治

    传送门 题意 初始时你有 $ s $ 元,接下来有 $ n $ 天. 在第 $ i $ 天,A券的价值为 $ A[i] $ ,B券的价值为 $ B[i] $ . 在第 $ i $ 天,你可以进行两种操 ...

  9. 51nod 1270 dp

    http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1270 简单的线性dp,最近狂刷水题真的是...药丸 差值最大得话要么是峰 ...

  10. 【poj2155】Matrix(二维树状数组区间更新+单点查询)

    Description Given an N*N matrix A, whose elements are either 0 or 1. A[i, j] means the number in the ...