[AS3]AS3调用文本类TextField源代码范例
[AS3]AS3调用文本类TextField源代码范例
[AS3]AS3调用文本类TextField源代码范例
- package
- {
- import flash.display.Sprite;
- import flash.events.TextEvent;
- import flash.net.URLRequest;
- import flash.net.navigateToURL;
- import flash.text.TextField;
- public class TextLearn extends Sprite
- {
- private var _txt:TextField;
- public function TextLearn()
- {
- _txt = new TextField();
- _txt.width = 300;
- _txt.wordWrap = true;
- addChild(_txt);
- _txt.htmlText =
- "单击<u><a href='event:geturl|http://www.cuplayer.com/|_blank'>酷播</a></u>在"+
- "新窗口打开一个到www.baidu.com链接。<br/>"+
- "单击<u><a href='event:load|someswf.swf'>这儿</a></u>则是在Flash中加载一个动画。<br/>"+
- "单击<u><a href='event:move|10'>这儿</a></u>则是将文本框移动10个像素";
- _txt.addEventListener(TextEvent.LINK, clickLink);
- trace(_txt.htmlText);
- }
- private function clickLink(evt:TextEvent):void
- {
- trace(evt.text);
- var cmdArray:Array = evt.text.split("|");
- trace(cmdArray);
- switch(cmdArray[0])
- {
- case "geturl":
- geturl(cmdArray[1], cmdArray[2]);
- break;
- case "load":
- loadswf(cmdArray[1]);
- break;
- case "move":
- movetxt(cmdArray[1]);
- break;
- default:
- trace(cmdArray);
- }
- }
- //cuplayer.com在新窗口中打开超链接
- private function geturl(url:String, target:String):void
- {
- var tmpRequest:URLRequest = new URLRequest(url);
- navigateToURL(tmpRequest, target);
- }
- //cuplayer.com提示:加载SWF
- private function loadswf(url:String):void
- {
- trace(url);
- }
- //cuplayer.com移动文本框
- private function movetxt(distance:Number):void
- {
- _txt.x += distance;
- }
- }
- }
来源:http://blog.csdn.net/borenliang/article/details/47702299
热门文章推荐
- [HLS]做自己的m3u8点播系统使用HTTP Live Streaming(HLS技术)
- [FMS]FMS流媒体服务器配置与使用相关的介绍
- [AS3]什么是M3U8,与HTML5的区别是什么
- AS2.0 让flash自适应全屏,并且不自动缩放
- [AS3]as3.0的sound类常用技巧整理
- [AS3]as3与ByteArray详解、ByteArray介绍、ByteArray用法
- 关于RTMP,RTMPT,RTMPS,RTMPE,RTMPTE协议的介绍
- [JS]分享浏览器弹出窗口不被拦截JS示例
请稍候...