1\(转)http://blog.csdn.net/hu36978/article/details/5796165

TFL

一般先创建TextFlow  通过控制flowComposer属性来控制文本容器

例如:

flow.flowComposer.addController(thisController);

文本容器是:

var thisController:ContainerController=new ContainerController(thisContainer,textPixelWidth, slatHeight);

thisController需要添加进显示列表

this.addChild(thisController)

刷新所有的文本容器

flow.flowComposer.updateAllControllers();

(注意,这样的文本是连接起来的,但他们却在不同的容器(Sprite)中)

创建TextFlow 有两种方法:

1@

flow = new TextFlow()

@2

flow=TextConverter.importToFlow(markup,TextConverter.TEXT_FIELD_HTML_FORMAT),  //html应用的比较多

flow=TextConverter.importToFlow(markup,TextConverter.TEXT_LAYOUT_FORMAT);

flow=TextConverter.importToFlow(markup,TextConverter.PLAIN_TEXT_FORMAT);

format的设置:

var format1:TextLayoutFormat = new TextLayoutFormat();

format1.color = 0x660000;

format1.fontFamily = "Arial, Helvetica, _sans";

format1.fontSize = 14;

format1.paragraphSpaceBefore=0;

format1.paragraphSpaceAfter=20;

var format2:TextLayoutFormat = new TextLayoutFormat();

format2.color = 0x990000;

format2.fontSize = 16;

format2.fontWeight = FontWeight.BOLD;

字体大小以及间距的设置:

flow.fontSize = fontSize;

flow.lineHeight = lineHeight;

flow.paddingTop = (flow.lineHeight - flow.fontSize)/2;

flow.paddingLeft = paddingLeft;

flow.paddingRight = paddingRight;

flow.columnCount=2; //列数 也就是默认的文本框TLF数

flow.columnGap=30;//两列间的距离

//format

flow.hostFormat = format1;

.

TEXT_FIELD_HTML_FORMAT的使用< TextConverter? 帮助文档里有讲解>

可以使用<a>以及<img> (图文混排)等的使用

flashx.textLayout.elements?包里的类都是对文本进行处排版的一些类

ParagraphElement类可以添加进TextFLow 而其他的例如SpanElement则添加进ParagraphElement

对应的html是的<TextFlow> <p><span ></span></p> </TextFlow>

flow.addChild(ParagraphElement实例)

paragraphElement.addCHild(SpanElement)实例

LinkElement也可以添加进paragraphElement

paragraphElement.addChild(LinkElement)

LinkElement就是链接 <a href=””>

var link:LinkElement = new LinkElement();

link.href="http://www.flashandmath.com/flashcs5/textcols";

link.target="_self";

link.linkNormalFormat={color: 0x0000CC,textDecoration: "underline"};

link.linkActiveFormat={color: 0x0000CC,textDecoration: "underline"};

link.linkHoverFormat={color: 0xCC0000,textDecoration: "underline"};

var linkspan:SpanElement = new SpanElement();

linkspan.text="Multicolumn Text on the Fly with AS3 Flash CS5";

link.addChild(linkspan);

elements包里类 使用 addChild 就相当于 <>嵌套

如上面 的link 和span 就是html的 <a href ="http://www.flashandmath.com/flashcs5/textcols"><span> Multicolumn Text on the Fly with AS3 Flash CS5</span></a>

使用外部的文件txt或者xnl都可以

下面是txt格式的:

将文本输出外部文件中 首先要保存flow里面的字符串

Txt格式:

var utString:String=TextConverter.export(flow,TextConverter.TEXT_LAYOUT_FORMAT,ConversionType.STRING_TYPE) as String;

xml 格式

var testxml:XML=TextConverter.export(flow,TextConverter.TEXT_LAYOUT_FORMAT,ConversionType.XML_TYPE) as XML;

在用filereference保存到本地:

var file:FileReference= new FileReference()

//file.save(outString,"text.txt");  txt格式

file.save(testxml,"my.xml");、、xml格式

加载外部上述文件格式的文本:

用 URLLoader加载外部文件并且保存在变量fileContent中

在使用

flow=TextConverter.importToFlow(fileContent,TextConverter.TEXT_LAYOUT_FORMAT);

flow.flowComposer.addController(new ContainerController(container, 570, 370));

flow.flowComposer.updateAllControllers();

这样外部文件就保存在flow的ContainerController里了

注意引入外部文件时 ,即 带有<TextFlow> 标签的使用

TextConverter.TEXT_LAYOUT_FORMAT类型

带html如,<img>的一般使用TextConverter .TEXT_FIELD_HTML_FORMAT

根据习惯内部的都有HTML 外部的都用TEXT_LAYOUT_FORMAT类型

Txt格式文件如下:

<TextFlow color="#000000" columnCount="2" columnGap="30" columnWidth="250" fontSize="14" lineBreak="toFit" paddingBottom="0" paddingLeft="0" paddingRight="0" paddingTop="0" paragraphSpaceAfter="20" paragraphSpaceBefore="0" verticalAlign="top" whiteSpaceCollapse="preserve" xmlns="http://ns.adobe.com/textLayout/2008"><p color="#990000" fontSize="16" fontWeight="bold"><span>Loading TLF Text at Runtime with AS3 in Flash CS5</span></p><p><span>The new TLF text features available in Flash CS5 are great for creating advanced text effects. Especially, if you can load text dynamically at runtime. If you use predefined text, you can always work with the Classic Text and MovieClips.</span></p><p color="#990000" fontSize="16" fontWeight="bold"><span>TLF Markup and Loading</span></p><p><span>In this tutorial, we show how to write an markup file that contains TLF text and formatting, load the file at runtime, and create a TLF TextFlow object containing loaded text. Since the documentation for TLF markup is a bit hard to find, we created a fla file, getmarkup.fla, that generates a correctly structured TLF markup file. See this tutorial's web page and getmarkup.fla file in the zip package for explanations. Once we have a correctly structured markup file, we can easily edit and customize it. Then we can load the text file at runtime and use the TextConverter class to import the information contained in the text file (text, layout, and formatting) into our instance of the TextFlow class. In this tutorial we use only some of the many formatting features of the TextFlow class. There are many more. You can find them in the AS3 Flash CS5 online documentation. See out tutorial: </span><a href="http://www.flashandmath.com/flashcs5/textcols" target="_self"><linkActiveFormat><TextLayoutFormat color="#0000cc" textDecoration="underline"/></linkActiveFormat><linkHoverFormat><TextLayoutFormat color="#cc0000" textDecoration="underline"/></linkHoverFormat><linkNormalFormat><TextLayoutFormat color="#0000cc" textDecoration="underline"/></linkNormalFormat><span>Multicolumn Text on the Fly with AS3 Flash CS5</span></a><span> for more examples of how to use these TextLayout classes.</span></p></TextFlow>

2\(转)http://hi.baidu.com/iscriptdada/item/23796aee0b06311b570f1d17

使用方法:

var _sprite:Sprite = new Sprite();

var _txFormat:TextLayoutFormat = new TextLayoutFormat(); // 默认样式

var html:String = "";

var _tf:TextFlow = TextConverter.importToFlow(html, TextConverter.TEXT_FIELD_HTML_FORMAT); //导入html,生成textflow

var _em:EditManager = new EditManager(new UndoManager()); //编辑选择、样式设置

_tf.interactionManager = _em;

_em.focusedSelectionFormat = new SelectionFormat(0xa8c6ee, 1.0, BlendMode.NORMAL, 0xa8c6ee, 1.0, BlendMode.NORMAL, 0);

_em.inactiveSelectionFormat = new SelectionFormat(0xa8c6ee, 1.0, BlendMode.NORMAL, 0xa8c6ee, 1.0, BlendMode.NORMAL, 0);

_em.unfocusedSelectionFormat = new SelectionFormat(0xe8e8e8, 1.0, BlendMode.NORMAL, 0xe8e8e8, 1.0, BlendMode.NORMAL, 0);

addChild(_sprite);

tf.format = _txFormat;

var _container:ContainerController = new ContainerController(_sprite,width, height); //显示容器控制器

_tf.flowComposer.addController(_container);

_tf.addEventListener(SelectionEvent.SELECTION_CHANGE, selectionChangeListener, false, 0, true);

_tf.addEventListener(StatusChangeEvent.INLINE_GRAPHIC_STATUS_CHANGE, graphicStatusChangeEvent, false, 0, true);

_tf.addEventListener(CompositionCompleteEvent.COMPOSITION_COMPLETE, compositionCompleteHandler, false, 0, true);

_tf.addEventListener(FlowOperationEvent.FLOW_OPERATION_COMPLETE, change);

1、 设置textflow失去焦点时的选中状态

var selectionManager:ISelectionManager = textFlow.interactionManager;//当选择部分不在活动窗口中时,用于绘制选择的 SelectionFormat 对象。

selectionManager.inactiveSelectionFormat = new SelectionFormat(0xa8c6ee, 1.0, BlendMode.NORMAL, 0xa8c6ee, 1.0, BlendMode.NORMAL, 0); //当选择部分不在焦点容器内但是位于活动窗口中时,用于绘制选择的 SelectionFormat 对象。

selectionManager.unfocusedSelectionFormat = new SelectionFormat(0xe8e8e8, 1.0, BlendMode.NORMAL, 0xe8e8e8, 1.0, BlendMode.NORMAL, 0);

2、通过TextConverter.importToFlow(html, TextConverter.TEXT_FIELD_HTML_FORMAT) 得到的textflow,不能改变color这样的属性,如果要改变这些属性,只能通过导入纯文本,然后设置样式。

3、让光标定位到文本最后

textflow.interactionManager.selectRange(textField.tf.getText().length,textField.tf.getText().length);

textflow.interactionManager.setFocus();

4、若显示区域小于文本总长度,通过滚动的方式,让显示区域显示对应的文字。_container.verticalScrollPosition 属性改变垂直滚动位置,

5、TextLayoutFormat  lineHeight属性:

表示行高合法值为 -720 到 720 范围内的数字。

合法值为 -1000% 到 1000% 范围内的百分比数字。

合法值包括 FormatValue.INHERIT。默认值未定义,指示未设置。如果在层叠期间未定义,则此属性将从一个祖代继承值。如果没有祖代设置了此属性,则其值为 120%。

6、TextFlow 深拷贝

var copiedTextFlow:TextFlow = textFlow.deepCopy() as TextFlow;

var someOtherTextFlow:TextFlow = new TextFlow();

someOtherTextFlow.replaceChildren(0, someOtherTextFlow.numChildren);

while (copiedTextFlow.numChildren){

// in order builds this is a little more complicated (psuedo code here you will have to debug it)//

var child = copiedTextFlow.getChildAtIndex(0);

// copiedTextFlow.removeChild(child);

// someOtherTextFlow.addChild(child)

someOtherTextFlow.addChild(copiedTextFlow.getChildAtIndex(0));

}

7、得到textline的方式

var flow:TextFlow = tArea.textFlow;

var composer:StandardFlowComposer = (flow.flowComposer as StandardFlowComposer);

var tfline:TextFlowLine = composer.getLineAt(composer.numLines-1);

var line:TextLine = tfline.getTextLine();

var factory:StringTextLineFactory = new StringTextLineFactory();

factory.compositionBounds = rect;

factory.createTextLines( useTextLines );

function useTextLines( line:DisplayObject ):void { }
var factory:TextFlowTextLineFactory = new TextFlowTextLineFactory();

factory.compositionBounds = new Rectangle(0,0,w,h);

factory.createTextLines(callback,textFlow);

function callback(tl:TextLine):void { }

8、通过导入htmltext生成textflow的方式,设置TextLayoutFormat属性无效。

因为直接改变这些属性也是设置html标签,不过是套在最外层,只有通过选中某部分,然后通过EditManager来改变才有效。

var pa:TextLayoutFormat = new TextLayoutFormat();

pa.color = 0x0000ff;

_em.selectAll();

_em.applyLeafFormat( pa, _em.getSelectionState() );

9、如何在缩小放大时自适应行高?

10、如何复制图片?

3\(转)http://zhidao.baidu.com/link?url=MInLapnqOpkw5evcTJsw3AIxa3HfnsuByeuEfoul2V_D749bSdFfdLQaBhLHy7P7MR3yRcy718WosfvtvyhysK

TLFTextField与TextField方法类似,区别就是在于TLFTextField能使用flashx包中的包含的TLF类的方法和属性。因此在对齐方式上,仍然采取了autoSize属性。控制文本字段的自动大小调整和对齐。TextFieldAutoSize 常数的可接受值为 TextFieldAutoSize.NONE(默认值)、TextFieldAutoSize.LEFT、TextFieldAutoSize.RIGHT 和 TextFieldAutoSize.CENTER。

如果 autoSize 设置为 TextFieldAutoSize.NONE(默认值),则不会进行调整。

如果 autoSize 设置为 TextFieldAutoSize.LEFT,会将文本视为左对齐文本,这意味着该文本字段的左边距保持固定,在右边可调整单个文本字段行。如果文本中包括换行符(例如 "\n" 或 "\r"),则会另外调整底边来适合文本的下一行。如果 wordWrap 也设置为 true,则仅调整文本字段的底边,而右边距保持固定。

如果 autoSize 设置为 TextFieldAutoSize.RIGHT,会将文本视为右对齐文本,这意味着该文本字段的右边距保持固定,可在左边调整单个文本字段行。如果文本中包括换行符(例如 "\n" or "\r")),则会另外调整底边来适合文本的下一行。如果 wordWrap 也设置为 true,则仅调整文本字段的底边,而左边距保持固定。

如果 autoSize 设置为 TextFieldAutoSize.CENTER,会将文本视为居中对齐文本,这意味着对单个文本字段行的调整将使其在左右边距间均衡分布。如果文本中包括换行符(例如 "\n" 或 "\r"),则会另外调整底边来适合文本的下一行。如果 wordWrap 也设置为 true,则仅调整文本字段的底边,而左右边距保持固定。

TLF相关资料的更多相关文章

  1. 全文检索解决方案(lucene工具类以及sphinx相关资料)

    介绍两种全文检索的技术. 1.  lucene+ 中文分词(IK) 关于lucene的原理,在这里可以得到很好的学习. http://www.blogjava.net/zhyiwww/archive/ ...

  2. React Test相关资料

    karma 前端测试驱动器,生产测试报告,多个浏览器 mocha js的测试框架,相当于junit chai,单元测试的断言库,提供expect shudl assert enzyme sinon.j ...

  3. iOS10以及xCode8相关资料收集

    兼容iOS 10 资料整理笔记 源文:http://www.jianshu.com/p/0cc7aad638d9 1.Notification(通知) 自从Notification被引入之后,苹果就不 ...

  4. Nao 类人机器人 相关资料

    Nao 类人机器人 相关资料: 1.兄妹 PEPPER :在山东烟台生产,http://www.robot-china.com/news/201510/30/26564.html 2.国内机器人领先公 ...

  5. GBrowse配置相关资料

    GBrowse配置相关资料(形状.颜色.配置.gff3) http://gmod.org/wiki/Glyphs_and_Glyph_Optionshttp://gmod.org/wiki/GBrow ...

  6. AssetBundle机制相关资料收集

    原地址:http://www.cnblogs.com/realtimepixels/p/3652075.html AssetBundle机制相关资料收集 最近网友通过网站搜索Unity3D在手机及其他 ...

  7. 转:基于IOS上MDM技术相关资料整理及汇总

    一.MDM相关知识: MDM (Mobile Device Management ),即移动设备管理.在21世纪的今天,数据是企业宝贵的资产,安全问题更是重中之重,在移动互联网时代,员工个人的设备接入 ...

  8. smb相关资料

    smb相关资料 看资料就上维基 https://en.wikipedia.org/wiki/Server_Message_Block#Implementation http://www.bing.co ...

  9. Linux命令学习总结之rmdir命令的相关资料可以参考下

    这篇文章主要介绍了Linux命令学习总结之rmdir命令的相关资料,需要的朋友可以参考下(http://www.nanke0834.com) 命令简介: rmdir命令用用来删除空目录,如果目录非空, ...

随机推荐

  1. RC522天线匹配参数【worldsing笔记】

    图为Device读卡器的参数值 EMC电路对读写距离影响不大:                   L3 和L4 固定为2.2uH:                  C11和C12也是固定值,如果P ...

  2. Javascript注意事项三【使用假值】

    0 //NumberNaN //Number'' //Stringfalse //Booleannull //Objectundefined //Undefined这些值全部都等同于false,但是它 ...

  3. Java与MySql数据类型对照表

    类型名称 显示长度 数据库类型 JAVA类型 VARCHAR L+N VARCHAR java.lang.String CHAR N CHAR java.lang.String BLOB L+N BL ...

  4. 楔子(xiē zǐ)

    戏曲.小说的引子.一般放在篇首,用以点明.补充正文,或者说引出正文或是为正文做铺垫.指旧小说的引子,通常放在小说故事开始之前,起引出或补充正文的作用.这不过是个楔子,下面还有正文.——<儒林外史 ...

  5. android widget的中文文档

    下文是我翻译于 App Widgets的文章,如果有不当之处请大家指出 app widget是一种嵌入在其他应用(例如主屏幕)和并且能偶接受间接性更新的小应用,你可以自己提供app widget pr ...

  6. 框架中web.xml中配置文件解析

    1.XSS指跨站脚本攻击 xss表示Cross Site Scripting(跨站脚本攻击),它与SQL注入攻击类似,SQL注入攻击中以SQL语句作为用户输入,从而达到查询/修改/删除数据的目的,而在 ...

  7. C#-获取datagriview选中行中某一列的值

    获取选中行中某一列的值: int index = dg_Product.CurrentRow.Index; //取得选中行的索引 txt_ProductId.Text = dg_Product.Row ...

  8. ORM之二:核心接口与扩展操作

    一.数据库提供者接口 /// <summary> /// 数据库提供者 /// </summary> public interface IDbProvider : IDispo ...

  9. Nginx+Tomcat动静态资源分离

    1 创建用户.用户组 useradd -g users www passwd www //设置密码,否则该用户不可用 groupadd -g 888 www //创建用户组 gpasswd -a ww ...

  10. 使用Eclipse建立Maven的SpringMVC项目

    非常感谢博客的大神,让我成功地构建项目 http://limingnihao.iteye.com/blog/830409 但在依照这篇文章构建构建时遇到了一些问题,在这里总结一下: 问题一.2.3.2 ...