AS3 getURL/navigateToURL(如何在AS3中创建可单击的链接)
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了AS3 getURL/navigateToURL(如何在AS3中创建可单击的链接)相关的知识,希望对你有一定的参考价值。
Shown in the source are the actual code, shorthand of the code, and Steven Sacks' simple-but-sweet rendition of getURL done in AS3, which requires the downloadable class from his site.
/////////////////////////////////////////////////// // Actual AS3 clickable-link code: my_btn.addEventListener(MouseEvent.CLICK, myBtnClicked); function myBtnClicked(e:MouseEvent):void { var url:String = "http://www.example.com/"; var request:URLRequest = new URLRequest(url); try { navigateToURL(request, '_blank'); } catch (e:Error) { trace("Error occurred!"); } } /////////////////////////////////////////////////// // Lazy shorthand. Reminder: navigateToURL SHOULD be in a try/catch my_btn.addEventListener(MouseEvent.CLICK, myBtnClicked); function myBtnClicked(e:MouseEvent):void { navigateToURL(new URLRequest("http://www.example.com/")); } /////////////////////////////////////////////////// // Implementation of Steven Sacks' AS3 getURL class import net.stevensacks.utils.Web; my_btn.addEventListener(MouseEvent.CLICK, myBtnClicked); function myBtnClicked(e:MouseEvent):void { Web.getURL("http://www.example.com/"); }
以上是关于AS3 getURL/navigateToURL(如何在AS3中创建可单击的链接)的主要内容,如果未能解决你的问题,请参考以下文章
ActionScript 3 AS3 SWFtrospection(as3swf)