ActionScript 3.0 using closures for event handlers

前端 未结 9 2078
挽巷
挽巷 2020-12-28 18:35

I tried doing this:

root.addEventListener(\"click\", 
   function () 
   { 
      navigateToURL(ClickURLRequest,\"_self\"); 
   });

And it

9条回答
  •  不知归路
    2020-12-28 19:14

    Just a side note on your code that I came across in the Flex In A Week set of tutorials on the Adobe web site. There, they said you should always use the constants for the event types rather than the string. That way you get typo protection. If you make a typo in the event type string (like say "clse"), your event handler will get registered but of course never invoked. Instead, use Event.CLOSE so the compiler will catch the typo.

提交回复
热议问题