=波波日志 > 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..
- ·13.1.为ArrayCollec..
- ·18.13.通过二进制So..
- ·22.7.使用ModuleLoa..
- ·JavaScript控制Flas..
- ·6.6.动态载入外部图..
- ·flash预加载进度条p..
博格Tag
- flash/flex/fcs/AIR(752)
- Asp.Net/C#/WCF(598)
- 操作系统及应用软件(376)
- JavaScript/Ajax(330)
- SQL及数据库(134)
- 黑客技术(115)
- Asp/VBScript(111)
- HTML/WML/CSS兼容/XML(102)
- PHP/apache/Perl(96)
- 网站排名及优化(96)
- 其他(75)
- showbo日志(66)
- lucene.net/分词技术(33)
- 计算机网络(26)
- 机械重工(26)
- C#设计模式(25)
- Google Maps开发(17)
- 日语学习(15)
- Canvas/VML/SVG(13)
- linux(11)
- 游戏开发(8)
- 正则表达式(5)
- Jsp/Java(4)
最新博文
- ·PHP socket套接字学..
- ·Warning Cannot sen..
- ·php与flash as3 soc..
- ·Flash XMLSocket使用..
- ·给flash右键增加自定..
- ·flash控件html及col..
- ·Flash加载XML文件CD..
- ·Flex3中文教程--hom..
随机博文
