Posted By

FlashJunior on 08/06/08


Tagged

cool easy faster


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

THEPWN3R
wirenaught


Call a function with arguments directly form a EventListener


 / Published in: ActionScript 3
 

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

  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  

You need to login to post a comment.