3 Replies Latest reply on Jun 24, 2011 10:09 AM by Peter Blazejewicz

    Flash Player 8 & Selection Class (overall not working via code)

    sinious Most Valuable Participant

      Hey all,

       

      I have a simple input box with an on-screen keyboard. When I type into the box using the on-screen keyboard (adding characters to the box programatically) the Selection class overall isn't letting me control the input.

       

      I'm assuming this is a scope issue of some sort. The input belongs to one class while the onscreen keyboard belongs to another.

       

      Is the Selection glass global or is it class-scoped? Even when I pass a reference from one class to another and request Selection.getCaratIndex() from the class that generated the input it continually returns -1 which is not correct.

       

      The kicker is I can make a new AS2 document, put an input box on the screen, add text to it (all programmatically), Selection.setFocus() the input, run Selection.setSelection() to the last index of the input and Selection.getCaratIndex() returns the valid number. So there's something funky going on when classes are involved.

       

      The only way the Selection class is working is if I use a real keyboard or mouse click, then it works fine. This isn't very useful in an on-screen keyboard context however.

       

      Are there any mines I should avoid when using the Selection class in an application where multiple other classes are involved? Is Selection really global or should I worry about scope with it?

        • 1. Re: Flash Player 8 & Selection Class (overall not working via code)
          sinious Most Valuable Participant

          Just posting a highly simplified version of this issue as proof, definitely not styled nicely . This is just 3 classes. A frame script instantiates the Main class. The Main class instantiates "ExampleOutput" which represents just an input TextField and "ExampleKeyboard" which is a ugly keyboard with all of 3 buttons.

           

          The red button is required to be pressed to Selection.setFocus() on the input element (a weird IDE glitch, this cannot be done until you click on flash itself). After that the left two buttons simply send the letter 'a' or 'b' to the input. I am tracing the values as I go.

           

          Export this using Flash Player 8, the Selection class overall is riding the failboat. It consistently returns the getCarat() at -1, also the selection range methods never return useful information.

           

          Export it with FP9 or FP10 and it works perfectly fine.

           

          http://www.filehorde.com/o/ExampleKeyboard.zip (10kb)

           

          Any ideas on this bizarre behavior? I just tried to pay Adobe to explain this with a paid support incident but apparently you cannot get help unless you volume license. This is apparently the last hope for non-volume users.

          • 2. Re: Flash Player 8 & Selection Class (overall not working via code)
            sinious Most Valuable Participant

            Multidmedia engineers helped me get around the issue and use a FP9 SWF so it's no longer an issue for me.

             

            Hope this helps anyone else who had to bring out an ancient AS2 FP8 requiring project stuck on inputs.

            • 3. Re: Flash Player 8 & Selection Class (overall not working via code)
              Peter Blazejewicz Level 4

              Hi,

               

              I think we should post how this is solved:

              - well, we trick Flash runtime

              - the Flash 8 exported movie just loads Flash 9 (or later) exported movie into itself

              loadMovie(path, _level0);

              and then - k!boom -  problem magically solved (we don't know how - but it works)

               

              @ominous93

              give me 10-point-er so I'd gain some more power before going next level

               

              hth,

              regards,

              Peter

              1 person found this helpful