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. 重看Decorator Pattern,联想到Delegate传递及Flags Enum--欢迎拍砖!

    话说装饰模式(Decorator)的动机是“动态地给一个对象添加一些额外的职责.就增加功能来说,Decorator模式相比生成子类更为灵活.[GOF <设计模式>]”.再次学到该模式,有感 ...

  2. iframe中的各种跳转方法

    iframe中的各种跳转方法(转)   一.背景A,B,C,D都是jsp,D是C的iframe,C是B的iframe,B是A的iframe,在D中跳转页面的写法区别如下. 二.JS跳转window.l ...

  3. Python中如何把一个UTC时间转换为本地时间

    需求: 将20141126010101格式UTC时间转换为本地时间. 在网上搜了好长时间都没有找到完美的解决方案.有的引用了第三方库,这就需要在现网安装第三方的软件.这个是万万不可的.因为真实环境不一 ...

  4. 关于Windows文件名和路径名的那些事

    博客搬到了fresky.github.io - Dawei XU,请各位看官挪步.最新的一篇是:关于Windows文件名和路径名的那些事.

  5. Windows下如何检测用户修改了系统时间并且把系统时间改回来

    博客搬到了fresky.github.io - Dawei XU,请各位看官挪步.最新的一篇是:Windows下如何检测用户修改了系统时间并且把系统时间改回来.

  6. 如何在线缩小jpg图片的大小

    直接使用在线PS保存成更小格式,即可! 在线PS网址:http://www.webps.cn/ 打开图片 点击保存 直接拖动滑动条就可以改变图片大小

  7. java 学习基础学习单词及java关键词

    在JAVA学习中我们难免会犯一些逻辑错误,语法错误,和一些运行错误,对于英语不好的人,就的记下下面的2常用单词,有助于我们提高在使用软件编写代码的速度和代码调试,能更便捷的找出错误,知道1中的保溜关键 ...

  8. SQLite使用教程8 Insert 语句

    http://www.runoob.com/sqlite/sqlite-insert.html SQLite Insert 语句 SQLite 的 INSERT INTO 语句用于向数据库的某个表中添 ...

  9. PostgreSQL的prepare 和 execute 动作背后

    我给PostgreSQL的源代码加入了调试信息以后,会有如下表现: 我执行Prepare: postgres=# prepare s(; PREPARE postgres=# 背后的反应: ** In ...

  10. 免费开放的API

    1)新浪IP地址查询API接口 http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=js&ip=IP地址 format有 js. ...