Revision: 9260
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at October 27, 2008 11:28 by Winkyboy
Initial Code
/////////////////////////////////////////////////// // 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/"); }
Initial URL
http://www.stevensacks.net/2008/02/06/as3-geturl-solved/
Initial Description
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.
Initial Title
AS3 getURL / navigateToURL (How to make clickable links in AS3)
Initial Tags
link
Initial Language
ActionScript 3