Adam Tworz’s Blog

February 27, 2009

onRelease

Filed under: Actionscript 3 Migration — Tags: , , , , — admin @ 11:05 pm

Actionscript 2

   mc1.onRelease = function() {
   }
   mc1.onRelease = null;

Actionscript 3

   import flash.events.MouseEvent; // if on timeline we don't need this line
   mc1.addEventListener(MouseEvent.CLICK, mc1_click);
   function mc1_click(e) {
   }
   mc1.buttonMode = true; // to have hand cursor when over it
   mc1.removeEventListener(MouseEvent.CLICK, mc1_click); // to remove action

Further differences:
1. if something is covering it, it won’t work even if invisible it will not work
2. function need to have one parameter or it will not work.
3. we need to remeber to remove this listeners when not needed or we’ll cause memory leaks

Powered by WordPress