Call a function with arguments directly form a EventListener


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

usually you made a function like "mybutonfunction" an call there e second function with parameters.. with this snippet, you can call it directly.


Copy this code and paste it in your HTML
  1. my_btn.addEventListener(MouseEvent.MOUSE_DOWN,
  2. function(e:MouseEvent)
  3. {
  4. new OpenWebsite("http://www.flashjunior.ch","_blank");
  5. }
  6. )
  7.  
  8. /* test class */
  9. package
  10. {
  11. import flash.display.MovieClip
  12. import flash.events.MouseEvent
  13. import flash.display.SimpleButton
  14. import flash.net.navigateToURL
  15. import flash.net.URLRequest;
  16.  
  17. public class OpenWebsite extends MovieClip
  18. {
  19. public function OpenWebsite(url:String,target:String):void
  20. {
  21. navigateToURL(new URLRequest(url),target);
  22. }
  23. }
  24. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.