By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
426,178 Members | 2,144 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 426,178 IT Pros & Developers. It's quick & easy.

Flex MouseEvent.MOUSE_UP MouseEvent.MOUSE_DOWN & listeners detect hold down mouse

P: 16
Hi everyone,

Yes, I need to use you guys as a sounding board once more :-)

I have a button that has two listeners one for mouse up and the other for mouse down and they point to the same function.

Expand|Select|Wrap|Line Numbers
  1. $btnRewind.addEventListener(MouseEvent.MOUSE_DOWN,onBtnBack);
  2. $btnRewind.addEventListener(MouseEvent.MOUSE_UP,onBtnBack);
  3.  
I want the end user to keep holding down their mouse to rewind and when they release the mouse, then I want the while loop to break.

As you can see by the code below, I've been trying a ton of stuff and I've commented out all the stuff that I'm not currently using

Expand|Select|Wrap|Line Numbers
  1.     private function onBtnBack(event:MouseEvent) : void
  2.     {
  3.         myCurrentPlayHead = Number($video.time);
  4.         //trace("$video.timecode "+$video.timecode);
  5.         //trace("$video.time "+$video.time);
  6.         //trace("event "+event);
  7.         //trace("myCurrentPlayHead "+myCurrentPlayHead);
  8.         //myConvertTime = String($video.timecode);
  9.         //myConvertTimeArray = myConvertTime.split(/:/);
  10.         //myCounterSec = Number(myConvertTimeArray[2]);
  11.         //myCounterFrames = Number(myConvertTimeArray[3]);
  12.         //myActualSeconds = myCounterSec * $video.fps;
  13.         //myActualFrames = myActualSeconds + myCounterFrames;
  14.         //trace("myActualFrames "+myActualFrames);
  15.         //myEndTime = Number($video.stream_end_time);
  16.         //trace("myEndTime "+myEndTime);
  17.  
  18.  
  19.         while(myCurrentPlayHead>0 && event.type == "mouseDown")
  20.         {
  21.             if(event.type == "mouseUp")
  22.             {
  23.                 break;
  24.             }
  25.             else
  26.             {
  27.                 myCurrentPlayHead = myCurrentPlayHead - 0.05;
  28.                 trace("myCurrentPlayHead rwnd "+myCurrentPlayHead);
  29.                 my_timedProcess = setTimeout(my_rewindFunction,1000/$video.fps);                
  30.             }
  31.         }
  32.  
  33.     }
  34.  
  35.     public function my_rewindFunction():void
  36.     {
  37.         if(myCurrentPlayHead > 0)
  38.         {
  39.             $video.pause();
  40.             $video.seek(myCurrentPlayHead);                
  41.         }
  42.     }
  43.  
Within the while loop, I have an if statement that basically checks for a mouseUp event, but it's like the function has already passed the event.type == "mouseDown" to the while loop, which means that the event.type == "mouseUp" will not arrive until the while loop has completed it's infinite loop.

BTW, speaking of infinite loops, I am tracing the var myCurrentPlayHead and it always goes below 0 into negative numbers, but the while loop still doesn't break.

Please help, I'm at a loss -- this should work.

Thanx n advance
Dec 18 '08 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.