0 Replies Latest reply on Mar 13, 2007 8:53 AM by wcdesign

    focus and replace text problem

      The code snippets below are for a floating character palette that detects the focus of a textInput field, then drops the character selected from the character palette into the textInput field. Where I'm having trouble is that the variable that stores the focused textInput field becomes "null" when the character palette is clicked. It works fine when a specific input field is defined, but this must accept all input fields available.

      Any ideas? This is for an urgent project of course.....

      // ------------- click of character palette

      function onClick(index)
      trace(chars.charAt(index)); // this is the character clicked
      _level0.thisFocus.replaceText(caret, caret, chars.charAt(index));

      Selection.setSelection(caret + 1, caret + 1);

      // ----------- this determines focus

      function onEnterFrame(Void)
      var focus = Selection.getFocus();

      _level0.thisFocus = focus;
      if (focus instanceof TextInput)
      this.TextInput = (TextInput)(focus);
      this.caret = Selection.getCaretIndex();