mouse - Actionscript 3 mouse_over play movie, mouse_out reverse movie -


i'm trying make flash buttons mouse_over animation plays in reverse on mouse_out. have working 1 of 3 movie clip instances.

i using e.currenttarget.play() instead of having function each movie clip, how do same playreverse function? tried putting e.currenttarget.prevframe() instead of mc1.prevframe() did not work. code follows:

mc1.addeventlistener(mouseevent.mouse_over,mover); mc2.addeventlistener(mouseevent.mouse_over,mover); mc3.addeventlistener(mouseevent.mouse_over,mover); mc1.addeventlistener(mouseevent.mouse_out,mout); mc2.addeventlistener(mouseevent.mouse_out,mout); mc3.addeventlistener(mouseevent.mouse_out,mout);  function mover(e:mouseevent):void {     stopplayreverse();     e.currenttarget.play(); }  function mout(e:mouseevent):void {     this.addeventlistener(event.enter_frame, playreverse, false, 0, true); }  function playreverse(e:event):void {     if (mc1.currentframe == 1) {         stopplayreverse();     } else {         mc1.prevframe();     } }  function stopplayreverse():void {     if (this.haseventlistener(event.enter_frame)) {         this.removeeventlistener(event.enter_frame, playreverse);     } } 

any idea how can fix this?

your function playreverse use mc1 how can work others movie clip.

if choose way can keep track of current movieclip playing in reverse. have add more logic if want play in reverse finish when passing on 1 clip another.

var currentmovieclip:movieclip=null;  function mout(e:mouseevent):void {     var mc:movieclip = e.currenttarget movieclip;      if (mc !== null) {      currentmovieclip = mc;      this.addeventlistener(event.enter_frame, playreverse, false, 0, true);     } }  function playreverse(e:event):void {     if (currentmovieclip==null) {        return;     }      if (currentmovieclip.currentframe == 1) {         stopplayreverse();     } else {         currentmovieclip.prevframe();     } } 

another way implies can have each clip finish play in reverse

function mover(e:mouseevent):void {     stopplayreverse(e.currenttarget movieclip);     e.currenttarget.play(); }  function mout(e:mouseevent):void {     var mc:movieclip = e.currenttarget movieclip;      if (mc !== null) {      mc.addeventlistener(event.enter_frame, playreverse, false, 0, true);     } }  function playreverse(e:event):void {     var mc:movieclip = e.currenttarget movieclip;       if (mc.currentframe == 1) {         stopplayreverse(mc);     } else {         mc.prevframe();     } }  function stopplayreverse(mc:movieclip):void {   if ((mc!==null) && mc.haseventlistener(event.enter_frame)) {     mc.removeeventlistener(event.enter_frame, playreverse);   } } 

Comments

Popular posts from this blog

c++ - Convert big endian to little endian when reading from a binary file -

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

unicode - Are email addresses allowed to contain non-alphanumeric characters? -