Flex的TextFlow
来源:互联网 发布:网络幼儿英语 编辑:程序博客网 时间:2024/04/28 05:15
TextFlow装载网页内容
示例代码:
textFlow = TextConverter.importToFlow(chapter.content,TextConverter.TEXT_FIELD_HTML_FORMAT,_config);
传入的第一个参数:包含html标签的字符串。
传入的第二个参数:第一个参数的格式。
传入的第三个参数:创建TextFlow的配置。
TextFlow中显示图片
TextFlow中图片资源会被处理为:InlineGraphicElement类的实例。这个类的source属性,如果只是给了一个URL,需要异步加载图片资源,资源加载情况会影响这个类的status属性 ,在status属性发生变化后,会抛出StatusChangeEvent事件。想要让TextFlow显示图片,需要监听TextFlow抛出的这个事件,并调用 IFlowComposer.updateAllControllers()。
TextFlow中控制图片的尺寸
上述InlineGraphicElement 类中,有几个属性和图片的尺寸相关,分别是:
- width 和 height 属性
- measuredWidth 和 measuredHeight 属性,表示加载时图形的宽度或高度
- actualWidth 和 actualHeight 属性,表示通过 width 或 height 以及 measuredWidth 或 measuredHeight 计算得到的图形的实际显示和合成宽度和高度
加载完图片后,图片的measuredWidth和measuredHeight是图片的实际尺寸,如果这两个值大于显示的限制,修改这个类实例的 width 和 height 值,就可以控制图片实际显示的大小。
以下示例代码,判断如果图片如果超出尺寸,做相应的缩小处理:
var imgElement:InlineGraphicElement=evt.element as InlineGraphicElement;trace(">>>>>>"+imgElement.source);trace("0w:"+imgElement.width,imgElement.measuredWidth,imgElement.actualWidth);trace("0h:"+imgElement.height,imgElement.measuredHeight,imgElement.actualHeight);var wFlag:Boolean=imgElement.measuredWidth>=cWidth;var hFlag:Boolean=imgElement.measuredHeight>=_containerHeight;if(wFlag||hFlag){ trace("1w:"+imgElement.width,imgElement.measuredWidth,imgElement.actualWidth); trace("1h:"+imgElement.height,imgElement.measuredHeight,imgElement.actualHeight); if(wFlag&&hFlag) { var wRate:Number=imgElement.measuredWidth/cWidth; var hRate:Number=imgElement.measuredHeight/cHeight; if(wRate>=hRate) { imgElement.width=cWidth; imgElement.height=imgElement.measuredHeight/wRate; }else { imgElement.height=cHeight; imgElement.width=imgElement.measuredWidth/hRate; } }else { if(hFlag) { imgElement.height=cHeight; }else if(wFlag) { imgElement.width=cWidth; } } trace("2w:"+imgElement.width,imgElement.measuredWidth,imgElement.actualWidth); trace("2h:"+imgElement.height,imgElement.measuredHeight,imgElement.actualHeight);}
阅读全文
0 0
- Flex的TextFlow
- Flex 4 :导出 TextFlow 对象
- Flex 4中如何设置TextFlow内超链接样式的例子
- pdflib textflow
- TextFlow 文本可视化
- [Flex]Flex的ApplicationDomain
- flex学习----flex的DataGrid
- flex 类似于flash的过渡效果 flex 教程 flex培训 flex源码 flex实例
- FLEX+Delphi,FLEX+Java,FLEX+C# 的聊天室
- Flex 3的下一版,遇見Flex 4...
- flex:Flex 组件的定位和布局
- (flex)一个简单的flex登陆实例
- [Flex]Flex绑定数据的方式
- Flex--Use Flex的命名空间 :mx_internal
- 写过Flex的非Flex人士
- Flex:Flex背景的渐变(二)
- flex与j2ee的结合(flex+Spring)
- flex flex AdvancedDataGrid的使用4
- android端登陆功能实现
- A Discriminative Feature Learning Approach for Deep Face Recognition 原理及在caffe实验复现
- Java实现-最小子数组
- bzoj 1001: [BeiJing2006]狼抓兔子
- POJ 2084 Game of Connections 笔记
- Flex的TextFlow
- Java并发编程与技术内幕:ArrayBlockingQueue、LinkedBlockingQueue及SynchronousQueue源码解析
- APP自动化测试2--androd的基础知识
- Redis安装与配制
- 设计模式之策略模式
- Selenium使用单例模式
- javascript:void(0)含义
- Android——ListView的优化
- Flex的mxml组件中进行图形绘制