/ Published in: ActionScript 3
URL: http://www.stevensacks.net/2008/02/06/as3-geturl-solved/
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.
Expand |
Embed | Plain Text
/////////////////////////////////////////////////// // 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/"); }
Comments
Subscribe to comments
You need to login to post a comment.

my_btn.pack.addEventListener(MouseEvent.CLICK, myBtnClicked);
function myBtnClicked(e:MouseEvent):void { try { navigateToURL(new URLRequest("/index.php"), "_self"); } catch (e:Error) { trace("Error occurred!"); } }
damarev has a nice packaged AS3 getURL : http://snipplr.com/view.php?codeview&id=14015
I created a very simple getURL class as well if anyone is interested: http://www.as3blog.org/?p=18
Oops, sorry about that last link.. here is the correct one: http://www.as3blog.org/?p=40
I am having the following problem. Can any one help me please.
1120: Access of undefined property btn_Enter.
btn_Enter.addEventListener(MouseEvent.CLICK, myBtnClicked);