Reusable URL function


/ Published in: ActionScript 3
Save to your folder(s)

Simplifies a button to use only one function for URL navigation.


Copy this code and paste it in your HTML
  1. btn1.addEventListener(MouseEvent.CLICK, myLink("http://www.MacEvellyIsAwesome.com/"));
  2. btn2.addEventListener(MouseEvent.CLICK, myLink("http://www.NoReallyHeIs.com/"));
  3. btn3.addEventListener(MouseEvent.CLICK, myLink("http://www.OkMaybeJustCool/"));
  4.  
  5.  
  6. function myLink(link:String):Function {
  7. var myLinkReturn:Function = function(evt:MouseEvent){
  8. navigateToURL(new URLRequest(link), "_self")
  9. }
  10. return myLinkReturn
  11. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.