6 Replies Latest reply on Apr 1, 2008 3:42 AM by rlc5611

    trouble controlling focus

    teemflmngo Level 1
      I am creating a movie clip called 'shirtFrame' at runtime on my main timeline that serves as a work area. The user can draw and add input text fields. If multiple text fields have been added, I want to be able to go back and change the formatting for each field. I have combo boxes on the main timeline that contain font and size choices, and they work on the text field that has focus. I have a focusListener that is used to get the text field instance name and pass it on to a variable that is then used by the combo boxes ... EXCEPT the listener does not distinguish between items on the movie clip and items in the main timeline. I select the text field in the clip and the Listener returns that instance name just like I want it to do. But then, I click on the combo box to change the font, and the Listener replaces it with the instance name of the combo box.

      For the life of me, I have not been able to figure out how to target only instances in my movie clip -- if that is what I really want to do. The code I'm using is below:
        • 1. Re: trouble controlling focus
          rlc5611 Level 1
          It sounds like your textfields in the clip are created dynamically. Why not just set an onSetFocus handler for each new textfield that is created in the clip at the time of the creation?
          • 2. Re: trouble controlling focus
            teemflmngo Level 1
            Sounds reasonable, I don't have the experience yet to have thought of that. I'll give it a shot and let you know. Thanks!
            • 3. Re: trouble controlling focus
              teemflmngo Level 1
              Alright, I still don't know enough about ActionScript to make this work. I am trying to target only those instances in the 'shirtFrame' movie clip. The first section of code successfully places the input text fields on the stage, but then the second section of code still doesn't work.
              • 4. Re: trouble controlling focus
                rlc5611 Level 1
                I added in a "yloc" just for testing
                • 5. Re: trouble controlling focus
                  rlc5611 Level 1
                  I also didn't see your "d++" before I put mine in but I just now saw it. One of them is unnecessary.
                  • 6. Re: trouble controlling focus
                    rlc5611 Level 1
                    I was looking at what your script does and the border seemed a bit awkward. The easier solution is to not create a border when you make the textfield and only show the border when it is in focus. But you may like the borders to show up. You may also have to different "frames" that need to work independently. So I made a second frame that I called "jacketFrame" for lack of a better name and also gave it its own button for adding text. The attached script creates textfields in those two frames. I left the borders on but now when you focus on any textfield in a frame, the borders not focused go away.

                    Another difference between the two is that the jacketFrame highlights the focused text up to the insertion point. I have never been able to make that work right with autoSize so I used a different method.