2 Replies Latest reply on Mar 24, 2009 2:40 PM by madfreaking

    Selection.setFocus() weirdness

    madfreaking
      Hi All,
      I am getting a bug in Flash player and also in the Flash Test Movie publish involving the Selection.setFocus() method (authored using Flash 8).

      I have 3 movie clips that require focus toggled between them via keyboard directional arrow input. Those clips are:

      - musicVolume_mc
      - effectsVolume_mc
      - speechVolume_mc

      I initially set the focus to the first movieClip:

      Code:

      Selection.setFocus("musicVolume_mc");


      and then each movieClip uses the following code example placed on the clip itself to target the next clip;


      Code:
      on(keyPress "<Up>"){
      Selection.setFocus("_parent.speechVolume_mc");
      }
      on(keyPress "<Down>"){
      Selection.setFocus("_parent.effectsVolume_mc");
      }


      Trouble is, the focus doesn't get passed as you would expect between each of the 3 clips, it gets stuck and jumps to the wrong clip....it's quite strange and frustrating. Has anyone had this issue?

      What do other people use to set Focus between movieClips reliably..?
      thanks
      mitchell
        • 1. Re: Selection.setFocus() weirdness
          rlc5611 Level 1
          I have had a lot of problems with the focus manager in the past. For some reason the focus manager seems to be slower than AS you execute to invoke it. I got around my problem by using setInterval to incorporate a very short (10 ms) delay before trying to change focus.
          • 2. Re: Selection.setFocus() weirdness
            madfreaking Level 1
            thanks for your reply,
            I managed to solve the problem by disabling the tabEnabled setting with is by default set to "true" and clashes with keyboard arrow input..

            Code:
            instanceName.tabEnabled=false;


            Also, if anyone else has this issue in future, relative paths inside the setFocus parameter didn't work for me....so use absolute ones instead, as in the following example.

            Code:
            Selection.setFocus("_root.audioOptions.effectsVolume_mc");

            cheers