1 Reply Latest reply on Jul 29, 2006 6:27 PM by butcho

    detect mouse over a textfield and out...

    julieta
      Hi, I am new to flash, and I wonder if someone could help me. I have a dynamic text field on the stage. I want to be able to do the following: when the user rolls over the text, the text changes its content, continuously displaying different texts out of an array that I have populated with texts. This should only stop when the user rolls the mouse out of the field.
      I have the array and the textfield. The question is: how do I know when the mouse is over this field? I have used hitTest on another project but I think that jus works with movieclips, and I also tried an invisible button on top. The problem is that the action of getting text out of the array should be infinite, going through the array as many times as necessary, while the mouse is on the field. I tried onRollover, but then i wouldn't be able to break the loop. So I need something like:

      While the mouse is on the button, or on the text field, do this. As soon as the mouse is out of it, stop.

      I did this in director once, but flash logic is different...

      Could someone give me please a hint?

        • 1. detect mouse over a textfield and out...
          Hi,

          try something like this:

          assume your textfield is called textBox and put it in a movieclip called myMcBtn. Assume also that your array is called textArray.

          var textArray:Array = ["me", "you", "them", "us", "my dog", "and everyone else"];
          var loop:Number;
          var myArrayPosition:Number = 0;

          myMcBtn.onRollOver = function(){
          loop = setInterval(startTextLoop, 2000);
          }
          myMcBtn.onRollOut = function(){
          stopTextLoop();
          }

          function startTextLoop(){
          myMcBtn.textBox.text = textArray[myArrayPosition];
          myArrayPosition++;
          if(myArrayPosition >= textArray.length){
          myArrayPosition = 0;
          }
          }

          function stopTextLoop(){
          clearInterval(loop);
          }