使用方法: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、如何复制图片?

 

还有一些问题没弄懂的,,一定得仔细看看源码才行呀!!!