8 Replies Latest reply on Apr 27, 2009 5:32 AM by Barna Biro

    On change: (Flex Properties)

    Thomas Garrod Level 1

      I'd like to know how to use this. I've set an input text field with initial text with a style of italics, I'd like to have it change to normal when the user enters new text. I can't find anything to explain the proper syntax, and what I'm doing doesn't work:

       

      change="text.normal"

       

      I find the Flex help completely mystifying. I click on the Help button; I perform searches; I get nothing. It is this way for every single question. I must presume that this help system has the answers if I can only find the secret password. If someone has succeeded in finding the answer using help, I'd appreciate hearing how they did it.

        • 1. Re: On change: (Flex Properties)
          Michael Borbor Level 4

          Within an TextArea you could do that using htmlText, how do you usually make a search in the flex builder help?

          • 2. Re: On change: (Flex Properties)
            run,ryan! Level 3
            change="thisTextId.styleName='normalFontStyleName'"

            and define a style named 'normalFontStyleName' which include a normal font style, and you probably want to define another italic font style name to change it back as well

            • 3. Re: On change: (Flex Properties)
              Thomas Garrod Level 1

              How do I usually search in Flex? I click on the help button and enter a search term. For example, I did a search on "On change," Properties panel, 'change=""'  In every case, a whole lot of unrelated or distantly related stuff comes up.

               

              I'd really like to know what that field is for if not for what I thought it was for.

              • 4. Re: On change: (Flex Properties)
                Michael Borbor Level 4

                In Flex Builder if you have a line of code like this for instance

                 

                <mx:DataGrid id="myDG" />
                

                 

                If you select the word DataGrid or at least have the text cursor somewhere around this word, pressing Shift+F2 will take you to the language reference about that class and there you'll probably find what you want, the methods, properties, styles and so on. The thing is that you aren't finding anything useful is because in Flex there isn't anything like on Change, however there's a event change that a lot of components dispatch. Also in the flex help search, next to the search input, there's a link that says search scope there you can refine where the help system looks for info too.

                • 5. Re: On change: (Flex Properties)
                  Thomas Garrod Level 1

                  "The thing is that you aren't finding anything useful is because in Flex there isn't anything like on Change, however there's a event change that a lot of components dispatch."

                   

                  Thank you Michael. The Shift+F2 will probably come in handy. You said above that there isn't anything like "on Change." This is might be true (I'm sure it is if you say so) with respect to coding, but there certainly is a field in the properties panel called "On change:" and I'm still wondering what that is. I'm also wondering how to find an explanation of the interface (this part, and other parts) through help. I have attached an image of the Properties panel so show that I'm not imagining this field.

                   

                  From an interface design perspective, people like me are perfect testors. You might say I should intuitively get the answer, but if I don't, the interface is at fault. Programmers don't buy this line of reason, and that is why interface design sucks. Because programers design interface, but don't test them.

                  • 6. Re: On change: (Flex Properties)
                    Michael Borbor Level 4

                    Yes I forgot about that part, it's true and there are other properties on click too, so there are a bit misleading you're right, if you're developing a Flex app, most likely you'll have to go to the code view so I don' think that'll be a problem. I can't see your image, sometimes it takes a long time for the forum to upload image, you could upload it somewhere else and post the link.

                    • 7. Re: On change: (Flex Properties)
                      Michael Borbor Level 4

                      I saw your image, as I told you before you were right if you want look about what  the change event does in the textinput I recommend you to just type in the search box: TextInput and then choose the language reference that says mx.controls.TextInput and then look at the events and there you'll find the change event and what it triggers.

                      • 8. Re: On change: (Flex Properties)
                        Barna Biro Level 3

                        Hello Thomas,

                         

                        Listening for a change event is not really ok because if I'm not mistaking, a change event is triggered even if the user types someting into the TextInput( and you don't want events to trigger on every character you type into the field; except, if that's the purpose of your application ). A much cleaner approach would be to listen for focusIn and focusOut events and combine these with a custom TextFormat object.

                         

                        http://www.igorcosta.com/flex3/doc/flash/text/TextFormat.html

                        http://livedocs.adobe.com/flex/3/html/help.html?content=Working_with_Text_12.html

                         

                        You would be doing something like this:

                         

                        1. Create a TextFormat object that will handle the text formatting from "normal" to "italic".
                        2. Add a focusIn and focusOut listener to your TextInput.
                        3. When the user focuses the input field then inside the focusIn handler, simply apply the correct TextFormat to your TextInput( in this case, you'd be applying a format that will display the text the user enters as "italic" ).
                        4. When the TextInput looses focus then inside the focusOut handler you'd apply the TextFormat object again, but this time, without italic, causing your text to display as "normal text" once more.

                         

                        Simple and more efficient than trying to do the same thing with a change event.

                         

                        Best regards,

                        Barna Biro