1 Reply Latest reply on Mar 10, 2008 7:10 PM by Zealouse

    bug in Flash

    Zealouse Level 1
      setFocus(null); doesnt work for either the combbox nor a textfeild.

      I can detected "focusOut" with the combobox but not a text feild. If I try to set focus to another text using "focus out" with the combobox I get an infinite loop error...So I can work with just a text feild but I can not detect a "focusOut" with a text feild, unless another text feild is selected.


      I just need to either set focus to another text feild or remove focus alltogether if the user left clicks any where outside of a textfeild.

      I've even tryed creating a text feild setting focus and removing it but still no go...Here is all my attemps to get it to work...but still isnt working:


      mybutton.onPress = function() {
      first_txt.setFocus(null);
      };
      //////normal Text/////////////////////////////////////////////
      first_txt.onKillFocus = function(newFocus:Object) {
      trace("text OUT");
      };
      first_txt.onSetFocus = function(oldFocus:Object) {
      trace("text IN");
      };
      //////////////////////////////////////////////////
      ////////////////END TEXT/////////////////////////////////////////////////



      /////////CB ON OUT////////////////////////////////////////
      /////////////////////////////////////////////////
      var mdiListener:Object = new Object();
      mdiListener.focusOut = function() {
      first_txt.setFocus(null);
      trace("CB out");
      };
      my_cb.addEventListener("focusOut",mdiListener);

      ////////////CB ON IN//////////////////////////////
      var mdiListener2:Object = new Object();
      mdiListener2.focusIn = function() {
      trace("CB IN");
      my_cb.open();
      };
      my_cb.addEventListener("focusIn",mdiListener2);
      /////////////////////////////////////////////////////////
      ////////////END////////////////////////////////////////////



      //////maybe try calling a function from killfocus????////////////////////////
      mykill = function () {
      Selection.setFocus("mditext");
      };
      ///////////////////////////////////////////
      /////////////////END/////////////////////////////////


      ////////////MAYBE CREATE A TEXT FEILD AND GIVE IT FOCUS/////////
      this.createEmptyMovieClip("killFocus",this.getNextHighestDepth());
      this.killFocus.onRelease = function() {
      focusManager.setFocus(this.killFocus);
      this.killFocus.removeMovieClip();
      };
      ////////////////////////////////////////////
      /////////END//////////////////////////////////////////
        • 1. bug in Flash
          Zealouse Level 1
          Okay for anyone one else that has the problem of :
          Selection.setFocus
          you have to delay before redirecting focus..of around 250 ms

          var refreshmeTimer:Number = setTimeout(delayedFunction, 250, "two second delay");

          function delayedFunction() {

          clearTimeout(refreshmeTimer);//refresh

          //Selection.setFocus(null);
          Selection.setFocus("mditext");
          }



          my_cb.textField.size = 16;
          //_root.focusManager = true;

          // Create Listener Object.
          var cbListener:Object = new Object();
          cbListener.open = function(evt_obj:Object) {
          //trace("The ComboBox has opened.");
          };
          cbListener.close = function(evt_obj:Object) {
          //trace("The ComboBox has closed.");
          _root.nokeys = false;

          };
          cbListener.focusIn = function() {
          _root.nokeys = true;
          my_cb.open();
          };

          cbListener.focusOut = function() {
          trace("out");
          clearTimeout(refreshmeTimer);

          var refreshmeTimer:Number = setTimeout(delayedFunction, 250, "two second delay");

          function delayedFunction() {

          clearTimeout(refreshmeTimer);//refresh

          //Selection.setFocus(null);
          Selection.setFocus("mditext");
          }
          };


          cbListener.change = function(evt_obj:Object) {
          //trace(evt_obj.target.selectedItem.label);
          fscommand("Code", evt_obj.target.selectedItem.label);
          };

          // Add Listener.
          my_cb.addEventListener("focusOut",cbListener);
          my_cb.addEventListener("open",cbListener);
          my_cb.addEventListener("close",cbListener);
          my_cb.addEventListener("focusIn",cbListener);
          my_cb.addEventListener("change",cbListener);




          // Respond to the user pressing the Enter key after adding a new item name.
          function enterListener(evt_obj:Object) {
          if (evt_obj.target.value != '') {
          evt_obj.target.addItem({data:evt_obj.target.value, label:evt_obj.target.value});
          //Selection.setFocus("mditext");
          }
          //trace(evt_obj.target.value);
          //evt_obj.target.editable = false;
          evt_obj.target.selectedIndex = evt_obj.target.dataProvider.length-1;
          _root.mdiA = false;
          fscommand("Code", evt_obj.target.value);
          _root.nokeys = false;
          //trace(evt_obj.target.value);
          }
          my_cb.addEventListener("enter",enterListener);
          //////////////////////////////////////////////////////////////////////////