=波波日志 > flash/flex/fcs/AIR > 9.25.在文本框里添加超链接=
[转]9.25.在文本框里添加超链接
问题
我想在文本框里加入超链接
解决办法
利用HTML <a href> 标签设置文本框的htmlText 属性,也可用TextFormat 对象的url属性
讨论
两种方法都有个前提那就是文本框的html 属性必须先设为TRue:
在文本框的htmlText 属性里设置HTML超链接标签<a href>:
还可指定目标窗口的打开方式:
当鼠标移到超链接上时鼠标图标会变成手型图标,下面给超链接加上下划线和颜色:
另外用TextFormat对象的url属性也可达到HTML标签同样的效果:
通过TextFormat 对象的target 属性设置链接打开窗口方式:
加上颜色和下划线:
超链接可以是http或https协议,也可以是其他协议如邮件消息:
用CSS是最完美的,它提供了超链接的a:link, a:active,和a:hover 样式:
我想在文本框里加入超链接
解决办法
利用HTML <a href> 标签设置文本框的htmlText 属性,也可用TextFormat 对象的url属性
讨论
两种方法都有个前提那就是文本框的html 属性必须先设为TRue:
+展开
-ActionScript
field.html = true;
在文本框的htmlText 属性里设置HTML超链接标签<a href>:
+展开
-ActionScript
field.htmlText = "<a href='http://www.rightactionscript.com'>Website</a>";
还可指定目标窗口的打开方式:
+展开
-ActionScript
field.htmlText = "<a href='http://www.rightactionscript.com' target='blank'>Website</a>";
当鼠标移到超链接上时鼠标图标会变成手型图标,下面给超链接加上下划线和颜色:
+展开
-ActionScript
var htmlLink:String = "<font color='#0000FF'><u>";
htmlLink += "<a href='http://www.rightactionscript.com'>Website</a>";
htmlLink += "</u></font>";
field.htmlText = htmlLink;
htmlLink += "<a href='http://www.rightactionscript.com'>Website</a>";
htmlLink += "</u></font>";
field.htmlText = htmlLink;
另外用TextFormat对象的url属性也可达到HTML标签同样的效果:
+展开
-ActionScript
field.text = "Website";
var formatter:TextFormat = new TextFormat( );
formatter.url = "http://www.rightactionscript.com/";
field.setTextFormat(formatter);
var formatter:TextFormat = new TextFormat( );
formatter.url = "http://www.rightactionscript.com/";
field.setTextFormat(formatter);
通过TextFormat 对象的target 属性设置链接打开窗口方式:
+展开
-ActionScript
field.text = "Website";
var formatter:TextFormat = new TextFormat( );
formatter.url = "http://www.rightactionscript.com/";
formatter.target = "_blank";
field.setTextFormat(formatter);
var formatter:TextFormat = new TextFormat( );
formatter.url = "http://www.rightactionscript.com/";
formatter.target = "_blank";
field.setTextFormat(formatter);
加上颜色和下划线:
+展开
-ActionScript
field.text = "Website";
var formatter:TextFormat = new TextFormat( );
formatter.color = 0x0000FF;
formatter.underline = true;
formatter.url = "http://www.rightactionscript.com/";
field.setTextFormat(formatter);
var formatter:TextFormat = new TextFormat( );
formatter.color = 0x0000FF;
formatter.underline = true;
formatter.url = "http://www.rightactionscript.com/";
field.setTextFormat(formatter);
超链接可以是http或https协议,也可以是其他协议如邮件消息:
+展开
-ActionScript
field.text = "email";
var formatter:TextFormat = new TextFormat( );
formatter.color = 0x0000FF;
formatter.underline = true;
formatter.url = "mailto:joey@person13.com";
field.setTextFormat(formatter);
var formatter:TextFormat = new TextFormat( );
formatter.color = 0x0000FF;
formatter.underline = true;
formatter.url = "mailto:joey@person13.com";
field.setTextFormat(formatter);
用CSS是最完美的,它提供了超链接的a:link, a:active,和a:hover 样式:
+展开
-ActionScript
var css:StyleSheet = new StyleSheet( );
css.parseCSS("a {color: #0000FF;} a:hover {text-decoration: underline;}");
field.styleSheet = css;
field.html = true;
field.htmlText = "<a href='http://www.rightactionscript.com'>Website</a>";
css.parseCSS("a {color: #0000FF;} a:hover {text-decoration: underline;}");
field.styleSheet = css;
field.html = true;
field.htmlText = "<a href='http://www.rightactionscript.com'>Website</a>";
类别:flash/flex/fcs/AIR 作者:转载 日期:2010-02-26 【评论:1】
相关文章
- 防盗锁
日期:2010-7-28 16:53:58 IP:60.214.*.*
放松放松管理员回复(2010-7-28 20:01:44)
O(∩_∩)O~
发表留言
热门博文
- As+lightbox+js实现实时加载图片进度
- 21.8.使用Cairngorm框架生成器生成应用程序骨架
- 6.8.启动DataGrid拖拽功能
- 13.1.为ArrayCollection添加,排序和获取数据
- 18.13.通过二进制Socket发送和接收二进制数据
- 22.7.使用ModuleLoader载入模块
最新博文
- JavaScript调用flash.external.ExternalInterface.addCallback注册的函数在不同浏览器下的分析
- JavaScript获取执行flash中flash.external.ExternalInterface.addCallback注册的函数
- Flash XMLSocket使用总结
- 给flash右键增加自定义菜单
- flash控件html及color属性冲突问题
- Flash加载XML文件CDTATA节点内容被编码
随机博文
- 2.5.创建子类
- 6.6.处理DataGrid/AdvancedDataGrid相关事件
- 8.8.访问用户的麦克风并创建声音显示
- 15.13.读取音乐的声谱
- 第一章. ActionScript 语言基础
- 7.15.编写遮罩
广告商赞助

